필터 지우기
필터 지우기

I have 2 graphs , on the Y axis I have Acceleration in graph. 1 and Speed in graph 2. And on the X axis for both I have Period (Seconds). How can I create a third chart?

조회 수: 4 (최근 30일)
I have 2 graphs , on th
The third graph must have in Y the acceleration value and in X axis must have the displacement value. Thanks in advance for your help
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2024년 4월 25일
편집: Dyuman Joshi 2024년 4월 25일
Show us what have you tried yet.
What are the inputs you are working with? What is the expected output?
How are the first 2 graphs related to the graph you want to obtain?

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

채택된 답변

Lokesh
Lokesh 2024년 4월 25일
Hi Queren,
It is my understanding that you want to plot acceleration vs displacement, given acceleration vs time and velocity vs time.
To plot acceleration versus displacement, you need to integrate the velocity data over time to calculate displacement. For discrete data, numerical integration, such as "cumtrapz" (Cumulative trapezoidal numerical integration), can be used for this purpose.
Below is a sample MATLAB code snippet demonstrating how to achieve this:
time = linspace(0, 10, 100); % 0 to 10 seconds
velocity = sin(time); % Example velocity data
acceleration = cos(time); % Example acceleration data
displacement = cumtrapz(time, velocity);%cumulative trapezoidal integration
figure;
plot(displacement, acceleration);
xlabel('Displacement');
ylabel('Acceleration');
title('Acceleration vs. Displacement');
grid on;
Refer to the following MATLAB documentation for more information on "cumtrapz":

추가 답변 (2개)

Tony
Tony 2024년 4월 25일
If you want to make three graphs in one window, try subplots.
figure(1);
subplot(1,3,1);
plot([0 1], [0 1]);
title('Acceleration vs Period');
subplot(1,3,2);
plot([0 1], [0.5 0.5]);
title('Speed vs Period');
subplot(1,3,3);
plot([0 1], [1 0]);
title('Acceleration vs Displacement');

Sam Chak
Sam Chak 2024년 4월 25일
How about this?
figure(3) % create a 3rd graph
plot(displacement, acceleration) % make the plot

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by