1d function varies with time: plot
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I have a very simple problem:
Given is a known function u(x,t). I want to create a x-y-plot, where the x-values vary with the time.
I have no experience with this yet. Can someone tell me which function I need to plot this problem?
Thank you in advance!
채택된 답변
Cris LaPierre
2020년 11월 13일
0 개 추천
It would probably be a good use of your time to go through MATLAB Onramp. Ch 9 covers plotting, but it sounds like you might want to start at the beginning.
댓글 수: 8
SA-W
2020년 11월 13일
Yes, I should really start at the beginning.
But can you show me an example? Let us say I want to plot u(x,t)=x*t in the Intervalls (0,10) for both x and t. How does the Code look like?
Thank you again!
Cris LaPierre
2020년 11월 13일
SA-W
2020년 11월 13일
I know how to plot a simple function like
x=0:1:20; y=3.*y; plot(x,y);
or a surface in a 3D-plot.
But I do not know how I can add the time Dependance to the plot.
Is it really just the plot-function what I need?
Cris LaPierre
2020년 11월 13일
편집: Cris LaPierre
2020년 11월 13일
If you can share a specific problem, I might be able to provide a more specific answer.
SA-W
2020년 11월 13일
So lets say I have the function y(x)=x. I plot it with
x=0:1:20 y=x Plot(x,y)
No problem. Now I want to plot y(x,t)=x*t (a linear function where the slope is time-dependent)
So I want to have a plot-figure where I see how the slope changes in a given time Intervall (if I Look for instance 10 seconds on the Figure, I will see the curve y=10*x).
Could you please show me how that works?
Cris LaPierre
2020년 11월 13일
편집: Cris LaPierre
2020년 11월 13일
It sounds like you want to view the interaction of 3 variables. If you want a 2D visualization, then know that MATLAB treats columns as series. Create all the results in a single matrix, with each column containg the results for a specifc time. Plotting the matrix creates a line for each column. Use colors, markers and linestyles in conjunction with a legend to identify the results for a specific series.
x=0:20;
t=0:10;
y=x'*t; % formulated to give a 21x11 matrix
plot(x,y)
legend("t="+string(t),"Location","eastoutside")
xlabel("x")
ylabel("y")

●
The other option is to use a 3D plot (plot3, scatter3, mesh, surf, bar3, etc). This allows you to see the interplay of all 3 variables.
[X,T]=meshgrid(x,t);
Y=X.*T;
surf(X,T,Y)
xlabel("X")
ylabel("t")
zlabel("Y")

●
You can also use the Plot tab to help you identify available visualizations for a particular variable. See my answer here for details on how to do that. It holds true if you use ctrl+lt click to select multiple variables as well. If you select x,t and y, you'll see just those plots that support visualizing those 3 variables.

SA-W
2020년 11월 13일
Thank you!
But actually what I need is more a animation or Video. You plotted all the curves for 1 second to 10 seconds, so in total 10 curves for discrete timepoints .
I imagine it like: The figure opens. After 1 second, the figure shows the curve y=1*x, after 5 seconds y=5*x, after 10 seconds y=10*x. So it is a Video of how the x-valus change with time. Do you know what I mean?
Cris LaPierre
2020년 11월 13일
편집: Cris LaPierre
2022년 8월 12일
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
