Adding new lines to a plot using a for loop

10 ビュー (過去 30 日間)
Jack Meakin
Jack Meakin 2020 年 1 月 6 日
編集済み: KALYAN ACHARJYA 2020 年 1 月 6 日
I need to plot a graph with 5 lines from data in a for loop that changes with every loop ie an additional line must be plotted on the same figure for each time the loop is completed.
for i = 1:5
newmatrix = i * othermatrix + originalmatrixx;
figure
ksdensity(newmatrix(:,30))
end

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 1 月 6 日
編集済み: KALYAN ACHARJYA 2020 年 1 月 6 日
Please do use "hold on" within loop.
figure,
for i = 1:5
newmatrix = i * othermatrix + originalmatrixx;
[var1 var2]=ksdensity(newmatrix(:,30))
plot(??) %plot parameters
hold on;
end
Read here ksdensity

Community Treasure Hunt

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

Start Hunting!

Translated by