How do I increment "I" more than once in more than one range in a single for loop? Basically combine all for loops into a single loop with different "I" values.

1 次查看(过去 30 天)
for I = 6611:6648
R = TempDev.Vias(I).R;
xx = TempDev.Vias(I).xc+R*cos(phi);
yy = TempDev.Vias(I).yc+R*sin(phi);
hfssCylinder2(fid, "ViaSub" + num2str(I), 'Z', [ViasX(I), ViasY(I), 0], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I), 'Z', [ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "ViaSub" + num2str(I+6648), 'Z', [-ViasX(I), ViasY(I), 0], R, hsubstrate+hmicrostrip*2, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I+6648), 'Z', [-ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate+hmicrostrip*2, Units, Nsides);
end
for I = 6195:6375
R = TempDev.Vias(I).R;
xx = TempDev.Vias(I).xc+R*cos(phi);
yy = TempDev.Vias(I).yc+R*sin(phi);
hfssCylinder2(fid, "ViaSub" + num2str(I), 'Z', [ViasX(I), ViasY(I), 0], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I), 'Z', [ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "ViaSub" + num2str(I+6375), 'Z', [-ViasX(I), ViasY(I), 0], R, hsubstrate+hmicrostrip*2, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I+6375), 'Z', [-ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate+hmicrostrip*2, Units, Nsides);
end
for I = 6131:6162
R = TempDev.Vias(I).R;
xx = TempDev.Vias(I).xc+R*cos(phi);
yy = TempDev.Vias(I).yc+R*sin(phi);
hfssCylinder2(fid, "ViaSub" + num2str(I), 'Z', [ViasX(I), ViasY(I), 0], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I), 'Z', [ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate, Units, Nsides);
hfssCylinder2(fid, "ViaSub" + num2str(I+6162), 'Z', [-ViasX(I), ViasY(I), 0], R, hsubstrate+hmicrostrip*2, Units, Nsides);
hfssCylinder2(fid, "Via" + num2str(I+6162), 'Z', [-ViasX(I), ViasY(I), -hmicrostrip], R, hsubstrate+hmicrostrip*2, Units, Nsides);
end

回答(1 个)

Steven Lord
Steven Lord 2020-9-15
for k = [1:9 10:10:90 100:100:1000]
fprintf("The current value of k is " + k + newline)
end

类别

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