Equation in a loop that feeds an answer matrix
Mostrar comentarios más antiguos
Hello! I have this non loop code that I have been trying to turn it into a loop (so I can assign different values to "n" if I want to) but I can´t seem to figure it out. Any help is parreciated.
% Equation structure:
% s(i)=(90/n)*(i)
%with no loop
station=[1,2,3,4,5,6,7];
s1=(90/7)*1;
s2=(90/7)*2;
s3=(90/7)*3;
s4=(90/7)*4;
s5=(90/7)*5;
s6=(90/7)*6;
s7=(90/7)*7;
results=[s1,s2,s3,s4,s5,s6,s7];
%With a loop
n=7 %station number
results=[]
while (i <= n)
s(i)=(90/n)*(i);
i = i+1 ;
end
s=results;
disp(results);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!