Borrar filtros
Borrar filtros

I'm having a problem using plot function in a for loop. The plot figure is empty

1 visualización (últimos 30 días)
clear
clc
disp('Welcome to calculation program')
n=input('Please enter the number of iterations=');
x=input('Please enter the value of vector x=');
for i=1:1:n
x(i+1)=x(i)-((2*x(i)*tan(x(i))-1)/(2*tan(x(i))+2*x(i)*(sec(x(i))^2)));
fprintf('The value of iteration no.%1.0f of vector x is=%2.4f\n',i,x(i+1))
plot(i,x,'*r')
if x(i)==x(i+1)
break
end
end
for i=1:1:n
if x(i)~=x(i+1)
disp('The maximum number of iterations have been reached')
y=input('To re-run press 1 and to stop press any number=');
if y==1
midexam3
elseif y~=1
break
end
end
end

Respuesta aceptada

Image Analyst
Image Analyst el 9 de Dic. de 2022
Use hold on after plot
plot(i,x,'*r')
hold on

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by