Effacer les filtres
Effacer les filtres

Centering different yaxis plots at the same point

2 vues (au cours des 30 derniers jours)
BobbyRoberts
BobbyRoberts le 18 Mai 2020
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!

Réponse acceptée

Star Strider
Star Strider le 18 Mai 2020
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
.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by