Unrecognized function or variable 'row'.
Mostrar comentarios más antiguos
% exampleProgram.m
%
% This program produces an mx1 array of angles named
%of degrees and an mx1 array of the sines of the angles
%named sineAngle.
for angle =0:pi/10:2* pi
degrees (row, 1) = angle*180/pi;
sineAngle( row, 1 ) = sin (angle);
row = row +1;
end
% last line
Unrecognized function or variable 'row'.
1 comentario
SALAH ALRABEEI
el 22 de Jun. de 2021
your iterating variable is named "angle" not "row",
Respuestas (1)
row = 0 ;
for angle =0:pi/10:2* pi
row = row +1;
degrees (row, 1) = angle*180/pi;
sineAngle( row, 1 ) = sin (angle);
end
But preferred is below code:
angle =0:pi/10:2* pi ;
n = length(angle) ;
degrees = zeros(n,1) ;
sineAngle = zeros(n,1) ;
for i = 1:n
degrees (n) = angle(i)*180/pi;
sineAngle(n) = sin (angle(i));
end
Alos you can vectorize it. No loop needed.
angle =0:pi/10:2* pi ;
degrees = angle*180/pi;
sineAngle = sin (angle);
Categorías
Más información sobre Elementary Math 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!