Executing loops for specific number of times.

2 次查看(过去 30 天)
I have vectors x=[3 5 8 10] and v=1:12 starting from last element of vector x i.e 10 8 5 3 in reverse order i want to do following stuff
for i=1:12
if x=10
v(i)=v(i)-[real(p(i))*r(i)];
next if x=8
v(i)=v(i)-[real(p(i))*r(i)];
...
..
....
it has to complete till x=3
v(i)=v(i)-[real(p(i))*r(i)];
end
before hand i dont know how many elements are there in vector x and loop should start from last element of x to first...

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by