Plotting two vectors side by side.

조회 수: 33 (최근 30일)
Robbie McDermott
Robbie McDermott 2017년 11월 29일
댓글: Star Strider 2017년 11월 29일
I have two arrays that should plot to give the same (very similar) graphs. My first array, A, is 1 X 601 while my second array, B, is 1 X 1200. I want to re-scale one of these so I can plot them together and look at where they deviate from each other. What is the best way to re-scale them so that the minimums from array A are aligned to the minimums of array B? Or at least the two major minimums are aligned.
Any help would be greatly appreciated, I have been looking for a solution online however this one beats me.
Thanks in advance!
  댓글 수: 2
Sammit Jain
Sammit Jain 2017년 11월 29일
Can you share some information about the variable you're plotting it against and what is the size for that one?
Robbie McDermott
Robbie McDermott 2017년 11월 29일
Hi Sammit,
I haven't plotted at against anything yet. I just loaded up the data file and used the plot function to look at it.

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

채택된 답변

Star Strider
Star Strider 2017년 11월 29일
Use the linspace function:
A = rand(1, 601); % Create Data
B = rand(1, 1200); % Create Data
Ax = linspace(0, 601, 601); % X-Coordinate Vector For ‘A’
Bx = linspace(0, 601, 1200); % X-Coordinate Vector For ‘B’
figure(1)
subplot(2,1,1)
plot(Ax, A)
grid
subplot(2,1,2)
plot(Bx, B)
grid
Experiment to get the result you want.
  댓글 수: 2
Robbie McDermott
Robbie McDermott 2017년 11월 29일
Aww StarStrider!! Thats, great, I had seen this method posted else where but I couldn't see how it would help! Your explanation is much better! Thank you, that is a great help, my hat off to you!
p.s. cracking name too... star wars or LOTR reference?
Star Strider
Star Strider 2017년 11월 29일
As always, my pleasure!
I’m an Instrument Rated Private Pilot, and ‘StarStrider’ evolved from that. I’d not thought of the Star Wars or LOTR references before.
If my Answer solves your problem, please Accept it!

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

추가 답변 (1개)

M
M 2017년 11월 29일
I am not sure if it is really hat you want but here is an idea :
a=rand(10,1);
b=rand(15,1);
a and b are two vectors of different length and amplitude.
Using
plot(a);
hold on;
plot(b./max(b).*max(a))
you can plot a and b on the same graph and the maximum of a and b are of the same amplitude.

카테고리

Help CenterFile 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!

Translated by