Editing Line Type Settings for data in a for loop

조회 수: 2 (최근 30일)
mht6
mht6 2018년 1월 17일
답변: Birdman 2018년 1월 17일
I am plotting an array that enters a for loop 4 times and therefore produces 4 different arrays and 4 different curves. When plotting like this, how do I differentiate line type settings for different curves plotted by one plot command?
  댓글 수: 2
Birdman
Birdman 2018년 1월 17일
Can you share your code?
mht6
mht6 2018년 1월 17일
N = [20 13 56 72];
for i = 1:length(N)
% Create A matrix then..
f = ones(N(i),1);
h = 1/(N(i) + 1);
A_h = -A./(h.^2);
u = A_h\f;
x = linspace(0,1,N(i));
plot(x,u)

댓글을 달려면 로그인하십시오.

답변 (1개)

Birdman
Birdman 2018년 1월 17일
Do something like following:
N = [20 13 56 72];
line={'--','b--o','->','-*'};
for i = 1:length(N)
% Create A matrix then..
f = ones(N(i),1);
h = 1/(N(i) + 1);
A_h = -A./(h.^2);
u = A_h\f;
x = linspace(0,1,N(i));
plot(x,u,line{i});hold on;
end

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by