Same problem

Discussion in 'Programmer's Corner' started by Seio, Feb 16, 2012.

  1. Seio

    Thread Starter New Member

    Feb 16, 2012
    Hi to all,
    i have a problem with my simulink model. I' have write a function, with a for cicle, that work whit the entire array X and generate an array Y. This function work well if I stay in script mode. When I' m using in a MATLAB Function block, it don't work.
    The function is:
    Code ( (Unknown Language)):
    2. function S=F(R)
    3. S=zeros(1,length(R));
    4. for i=1:length(R)
    5.     S(i)=sum(R(1:i));
    6. end
    It seems that it can't read more than one element at a time, in fact the output array is equal than the input when I use this function in simulink
    Anyone have any suggestion?
    What I am doing wrong

    Thank you