필터 지우기
필터 지우기

What does this code mean?

조회 수: 1 (최근 30일)
Jennifer Yang
Jennifer Yang 2018년 7월 10일
편집: madhan ravi 2018년 7월 20일
Hello,
I'm still fairly new to MATLAB. I was looking through examples of how to plot my time dependent solution from t = 0, to t = t_max. I came across this example, but confused about how to interpret it.
x_f = 1; %Length of domain
maxt = 1; %Max simulation time
x = linspace(0,x_f,100); %xmesh
t = linspace(0,maxt,100); %tspan
% Plotting
hold all
for n = linspace(1,length(t),10)
plot(x,sol(n,:),'LineWidth',2)
end
Is this plotting the solution from t = 0 to t = 1 with 10 intervals inside it?
Thank you.

답변 (1개)

madhan ravi
madhan ravi 2018년 7월 11일
편집: madhan ravi 2018년 7월 20일
Actually there are some errors in the code.
linspace is a function which defines a vector from a starting to end point with the specified interval.
And the above code plots x and sol , here sol is not defined ! It is inside the loop so it must be a moving plot. It has nothing to do with t.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by