Unrecognized function or variable 'row'.

% 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
SALAH ALRABEEI el 22 de Jun. de 2021
your iterating variable is named "angle" not "row",

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 22 de Jun. de 2021
Editada: KSSV el 22 de Jun. de 2021
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.

Preguntada:

el 22 de Jun. de 2021

Editada:

el 22 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by