Info
This question is closed. Reopen it to edit or answer.
Run a vectorelement in a for loop
3 views (last 30 days)
Show older comments
Hi!
I have a vector x=[x(2),x(3),x(4),....,x(9)]. Now I want to change/run each element in a for loop. I did:
if true
x(2)=0.05:0.01:0.15;
x(3)=0.10:0.01:0.30;
x(4)=0.15:0.01:0.50;
x(5)=0.05:0.01:0.10;
x(6)=0.05:0.01:0.15;
x(7)=0.10:0.02:0.30;
x(8)=0.15:0.02:0.30;
x(9)=0.10:0.02:0.30;
N=length(x(2))*length(x(3))*length(x(4))*length(x(5))*length(x(6))*length(x(7))*length(x(8))*length(x(9));
%%---------------------Thickness variation------------------------- %%
numorder=0;
for ii=1:length(x(2))
for jj=1:length(x(3))
for kk=1:length(x(4))
for ll=1:length(x(5))
for mm=1:length(x(6))
for nn=1:length(x(7))
for oo=1:length(x(8))
for pp=1:length(x(9))
numorder=numorder+1;
run a function
end
Unfortunately the error is a common one, bur I dont understand the explanation. The Error is: In an assignment A(I) = B, the number of elements in B and I must be the same. I understand that I have to change the form of my code, but how it should be?
Thanks!
1 Comment
Michael Haderlein
on 5 Feb 2015
Huh, what are you going to do? The error comes from the lines where you write
x(.)=...
The right hand side is an array with, say, 10 elements while the left hand side is only one scalar. That doesn't match. Please tell us what's the purpose of the script, then we can help you. Btw, if you really want to vary the first element from 0.05 to 0.15 with 0.01 increments, the second one similarly and so on, you'll get about 500'000'000 values - are you sure you want that? That's also how often the function (run a function) will be executed. It could take quite some while...
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!