how to graph using loop?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Khang Nguyen
il 21 Nov 2020
Commentato: Khang Nguyen
il 21 Nov 2020
I want to calculate a problem and graph it
I want to graph i and area but it only show one point on my graph
% question1
clear all
a = 1
vectori = []
areavec = []
figure;
for i = 0:20
a = a + a
area = a *(1/8).^i
scatter(i,area)
end
0 Commenti
Risposta accettata
the cyclist
il 21 Nov 2020
Modificato: the cyclist
il 21 Nov 2020
Put the command
hold on
on the line after figure.
0 Commenti
Più risposte (1)
Setsuna Yuuki.
il 21 Nov 2020
Modificato: Setsuna Yuuki.
il 21 Nov 2020
You must change this:
clear all
a = 1
vectori = []% ??
areavec = []
figure;
for i = 0:20
a = a + a
areavec(i+1) = a *(1/8).^i %area --> areavec and areavec is a vector, not a scalar
end
i = 0:20;
scatter(i,areavec) %area --> areavec and graph must be out of cycle
4 Commenti
Vedere anche
Categorie
Scopri di più su Discrete Data Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!