ERROR: In an assignment A(I) = B, the number of elements in B and I must be the same.
Info
This question is closed. Reopen it to edit or answer.
Show older comments
EDIT: Discovered that obj.t should have been expressed as obj.t(obj.i) also. I was under the impression that I could have left that as a vector and the output would have been a vector, but apparently not. Problem solved.
--------------------------------------------------------------------
Hi all,
I'm having some trouble with the above error in a while loop, shown below:
while obj.w(obj.i) < 100
obj.dy(obj.i)=((((obj.Sw(obj.i))^2))^(1/2))*(cos((obj.w(obj.i)*obj.t)+obj.rad));
obj.y = obj.y + obj.dy(obj.i);
obj.i = obj.i + 1;
end
obj.Sw and obj.w are both 1x101 and obj.t is 1x30. Basically, I'm expecting the output to be a single 1x30 vector, representing a turbulence time history.
Can anyone see where I'm going wrong? I've created an identical loop in different programs before and had no previous trouble.
Thanks in advance.
Craig
Answers (1)
Image Analyst
on 10 Apr 2013
0 votes
Use .^ and .* instead of ^ and . Otherwise, if you don't put the dots before the operator, you're doing a matrix operation instead of an element by element operation.
1 Comment
Craig
on 10 Apr 2013
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!