Prev: Contour in a 3D domain
Next: dlmwrite inquiry
From: Fangjun Jiang on 3 Aug 2010 11:44 Do both in one command: set_param(BlockHandle,'InputValue','[1 2 3 4]','Table','[4 5 6 7']); Adam Chapman <adamchapman1985(a)hotmail.co.uk> wrote in message <c8ab433f-c1a0-4260-8cf4-438dc4f448e6(a)q22g2000yqm.googlegroups.com>... > I've made some code that goes through a list of code-generated > parameters that need to be assigned to simulink blocks. > > Since I have a lot of blocks to assign parameters to and those blocks > al have a different number of parameters, I thought it would make > sense to set all parameters individually, one at a time. > > I keep getting an error when I try to set the first parameter of a > lookup table with an array which is a different size to the one > previously set. > > for example, say I have a 2D lookup table with parameters: > InputValue=[1 2 3] > Table=[4 5 6] > > and i now try to assign [1 2 3 4] to the parameter 'InputValue' > MATLAB complains that 'InputValue' is now a different size to 'Table'. > But if it would just allow the next iteration in the loop to set > 'Table' there wouldn't be a problem! > > What can I do? > > Thanks in advance for any help > Adam
From: Adam Chapman on 3 Aug 2010 11:48 On Aug 3, 4:44 pm, "Fangjun Jiang" <f...(a)j.com> wrote: > Do both in one command: > > set_param(BlockHandle,'InputValue','[1 2 3 4]','Table','[4 5 6 7']); > > > > Adam Chapman <adamchapman1...(a)hotmail.co.uk> wrote in message <c8ab433f-c1a0-4260-8cf4-438dc4f44...(a)q22g2000yqm.googlegroups.com>... > > I've made some code that goes through a list of code-generated > > parameters that need to be assigned to simulink blocks. > > > Since I have a lot of blocks to assign parameters to and those blocks > > al have a different number of parameters, I thought it would make > > sense to set all parameters individually, one at a time. > > > I keep getting an error when I try to set the first parameter of a > > lookup table with an array which is a different size to the one > > previously set. > > > for example, say I have a 2D lookup table with parameters: > > InputValue=[1 2 3] > > Table=[4 5 6] > > > and i now try to assign [1 2 3 4] to the parameter 'InputValue' > > MATLAB complains that 'InputValue' is now a different size to 'Table'. > > But if it would just allow the next iteration in the loop to set > > 'Table' there wouldn't be a problem! > > > What can I do? > > > Thanks in advance for any help > > Adam- Hide quoted text - > > - Show quoted text - I know that can be done, but with my configuration I have many blocks with different numbers of parameters, so I would need a different command written out for each block with differing amounts of parameters. It would be a lot of tedious work. For example, I'd need a different command for a 2D lookup table than for a 3D lookup table.
From: Fangjun Jiang on 3 Aug 2010 12:00 Adam Chapman <adamchapman1985(a)hotmail.co.uk> wrote in message <25a2a1e4-7fce-4a64-a917-468869891211(a)u26g2000yqu.googlegroups.com>... > On Aug 3, 4:44 pm, "Fangjun Jiang" <f...(a)j.com> wrote: > > Do both in one command: > > > > set_param(BlockHandle,'InputValue','[1 2 3 4]','Table','[4 5 6 7']); > > > > > > > I know that can be done, but with my configuration I have many blocks > with different numbers of parameters, so I would need a different > command written out for each block with differing amounts of > parameters. It would be a lot of tedious work. For example, I'd need a > different command for a 2D lookup table than for a 3D lookup table. > > What do you mean "different command"? All are using the same command "set_param()", right? If you are talking about your own script command, you can always make your script command have the same calling syntax and arguments by careful design. For example, design your command called SetLookupTableData(BlockHandle, TableData), then, depending on the dimension of the TableData, you can apply set_param accordingly.
From: Adam Chapman on 3 Aug 2010 12:06 On Aug 3, 5:00 pm, "Fangjun Jiang" <f...(a)j.com> wrote: > Adam Chapman <adamchapman1...(a)hotmail.co.uk> wrote in message <25a2a1e4-7fce-4a64-a917-468869891...(a)u26g2000yqu.googlegroups.com>... > > On Aug 3, 4:44 pm, "Fangjun Jiang" <f...(a)j.com> wrote: > > > Do both in one command: > > > > set_param(BlockHandle,'InputValue','[1 2 3 4]','Table','[4 5 6 7']); > > > I know that can be done, but with my configuration I have many blocks > > with different numbers of parameters, so I would need a different > > command written out for each block with differing amounts of > > parameters. It would be a lot of tedious work. For example, I'd need a > > different command for a 2D lookup table than for a 3D lookup table. > > What do you mean "different command"? All are using the same command "set_param()", right? If you are talking about your own script command, you can always make your script command have the same calling syntax and arguments by careful design. For example, design your command called SetLookupTableData(BlockHandle, TableData), then, depending on the dimension of the TableData, you can apply set_param accordingly. by "different command", I meant I'd have to write out a differently formatet "set_param" command. e.g. for a 2D lookup I'd need: set_param(blockhandle,'param1','var1','param2','var2') and for a 3D lookup: set_param(blockhandle,'param1','var1','param2','var2','param3','var3') what i was trying to do is set individual parameters in a loop: for i=1:numberpfparameters set_param(blockhandle,'param_i','varI') end I guess your suggestion of putting the differently sized formatted set_param commands in a function would work. Thankyou, I was just hoping there's be a simpler solution
|
Pages: 1 Prev: Contour in a 3D domain Next: dlmwrite inquiry |