필터 지우기
필터 지우기

Centering different yaxis plots at the same point

조회 수: 2 (최근 30일)
BobbyRoberts
BobbyRoberts 2020년 5월 18일
답변: Star Strider 2020년 5월 18일
Hi. I am trying to plot arrays of which have different y ranges. For example, array1 could range from -1 to 1 while another may range from 1 to 3. An example of the code is as follows:
for j = 1:30
plot(array(1:shut(j),j));
end
As you see, each array (j) begins at a different y value. Is there a way I can have all of these arrays begin at the same y value graphically without altering the arrays themselves? The actual value of the y would not matter so long as the relative ranges are the same. Thanks in advance!

채택된 답변

Star Strider
Star Strider 2020년 5월 18일
Subtract the first y-value from each one and they all should begin at 0.
Example —
x = sort(rand(5, 20),2);
y = randi(20, 5, 20);
figure
hold on
for k = 1:size(x,1)
plot(x(k,:), y(k,:))
end
grid
figure
hold on
for k = 1:size(x,1)
plot(x(k,:), y(k,:)-y(k,1))
end
grid
.

추가 답변 (0개)

카테고리

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