From: Meagan on
Hi all,

I am working on a project and I have a quick question. In the example shown here:

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/embeddedmatlabfunction.html

the input is an array where vals(1,3)=4. Correct? I want to use this value in a calculation like number=vals(1,3)+7 but I keep getting an error 'Index expression out of bounds. Attempted to access element 3. The valid range is 1-1.' Is there any way to fix this or dose the valid range mean I can only use the first value in the array?

Thanks for your help,
Meagan
From: Michael Hosea on
In Simulink there is the notion of a 1-D array, so even though the constant
block makes it look like a 1x4 array, in reality Simulink only considers it
a 4-element one-dimensional array that is, in a sense, neither 4x1 or 1x4,
rather just plain length=4. I think you'll find that the Embedded MATLAB
block, which speaks MATLAB langauge, interpets this as a 4x1 array. So, you
could write "vals(3,1)", but to avoid the issue entirely, I would write
"vals(3)", which works perfectly for both row and column vectors.
--
Mike


"Meagan " <meagan.musselman(a)l-3com.com> wrote in message
news:hsf6j0$pk0$1(a)fred.mathworks.com...
> Hi all,
>
> I am working on a project and I have a quick question. In the example
> shown here:
> http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/embeddedmatlabfunction.html
>
> the input is an array where vals(1,3)=4. Correct? I want to use this value
> in a calculation like number=vals(1,3)+7 but I keep getting an error
> 'Index expression out of bounds. Attempted to access element 3. The valid
> range is 1-1.' Is there any way to fix this or dose the valid range mean I
> can only use the first value in the array?
>
> Thanks for your help,
> Meagan