Filter löschen
Filter löschen

The graph is not displayed

2 Ansichten (letzte 30 Tage)
Mathew Aibinu
Mathew Aibinu am 26 Aug. 2023
Beantwortet: Dyuman Joshi am 26 Aug. 2023
close all
clear all
x0 = 100;
r=1.02;
for j=1:1:5
x(1) = x0;
x(j+1) = r*x(j);
end
plot(j, x(j))
grid on

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 26 Aug. 2023
x0 = 100;
r=1.02;
%Bring the assignment out of loop, as it is not affected by the loop
x = x0;
%Define indices to loop over
j = 1:5;
for k=j
x(k+1) = r*x(k);
end
%Plot with markers to show the data points
plot(j,x(j),'bo-')
grid on

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by