Error code:The number of elements in B and I must be the same
Show older comments
Hi
I want to store data i calculated into a vector and then plot the vector but the next error pops up: A(I) = B, the number of elements in B and I must be the same.
This is the code i am talking about:
for i=0:360/5
mi_selectgroup(1)
mi_moverotate(0,0,5*i)
mi_analyze(0);
mi_loadsolution();
mo_seteditmode('contour')
mo_selectpoint((BUDSPL+0.175)*cos(HoekRK1r),(BUDSPL+0.175)*sin(HoekRK1r))
mo_selectpoint((BUDSPL+0.175)*cos(HoekPMr),(BUDSPL+0.175)*sin(HoekPMr))
flux_spoel(i+1)=mo_lineintegral(0);
end
(the language of the code comes from a programm named FEMM so don't worry about not recognizing it)
the point is that flux_spoel(i+1) doesnt have the same size as mo_lineintegral(0) and the size is growing each time the loop is executed. Thats what matlab is grumpy about, since i am quite new to matlab i don't really know how to solve this problem.
I tried applying flux_spoel1(i+1,1:length(mo_lineintegral(0)) = mo_lineintegral(0);
as my tutor told me to write it like this, i think then the lengths are the same in the end then but matlab gives an error code: The expression to the left of the equals sign is not a valid target for an assignment.
I don't want to bug my tutor every 5seconds so i came here.
I would be very gratefull to get some help and even more gratefull if someone tried to explain the solution rather than just writing new code so i can do it myself the next time :)
Thx in advance
Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!