Info

This question is closed. Reopen it to edit or answer.

error In an assignment A(I) = B, the number of elements in B and I must be the same.

1 view (last 30 days)
x1= 320.11; x2=2.42; x3=69.63; x4=1.39; S=x1*0.6; R=x3*0.7;
i=1:730;
if P(i)>E(i);
Pn(i)=P(i)-E(i); En(i)=0;
En(i) = E(i)-P(i);Pn(i)=0;
Ps(i)=(x1.*(1-(S/x1).^2)*tanh(Pn(i)/x1))/(1+(S/x1).*tanh(Pn(i)/x1));
Es(i)=(S.*(2-S/x1).*tanh(En(i)/x1))/(1+(1-S/x1).*tanh(En(i)/x1));
S(i)=S-Es(i)+Ps(i); the error is in this line can you help me pls

Answers (1)

Image Analyst
Image Analyst on 13 Apr 2014
Well if S is an array, you can't do
S(i) = S - anythingElse;
because you're trying to stick the whole S array (minus some other things) into a single element . Let's say S is a 10 element array, and i is 2. You'd be trying to stick 10 elements into 1 - it just doesn't work (unless S is a cell array, which it's not).

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!