Azzera filtri
Azzera filtri

Centering different yaxis plots at the same point

2 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Star Strider
Star Strider il 18 Mag 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
.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by