How can i correct the below Matlab code

for p=1:5
S0=[0.1 0.2 0.3 0.4 0.5];
D0=[2.1 2.2 2.3 2.4 2.5];
for rep1=length(S0(p))
for rep2=length(D0(p));
Sr=S0(rep1);
Du=D0(rep2);
end
end
I need to evaluate the below condition. How can i change the above code.
S0 1st value & D0 1st value;
S0 2nd value & D0 2nd value;
S0 3rd value & D0 3rd value;
S0 4th value & D0 4th value;
S0 5th value & D0 5th value.

 采纳的回答

S0 = [0.1,0.2,0.3,0.4,0.5];
D0 = [2.1,2.2,2.3,2.4,2.5];
for k = 1:numel(S0)
Sr = S0(k);
Du = D0(k);
... the rest of your code
end

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by