Plotting arrays with different sizes
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
HC98
am 26 Mai 2023
Bearbeitet: Star Strider
am 26 Mai 2023
I want to plot a function where the arrays are different sizes
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2];
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma.^2 - x./b);
How can I do this? Obviously
arrays have incopatible sizes
so this will not work. It would be unwise at best to do
plot(x, 2.*(gamma(1)^2 - x./b), 'b')
% etc...
0 Kommentare
Akzeptierte Antwort
Star Strider
am 26 Mai 2023
Bearbeitet: Star Strider
am 26 Mai 2023
Transpose ‘gamma’ to create a family of curves —
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2];
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma(:).^2 - x./b)
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
legend("\gamma = "+string(gamma(:)), 'Location','best')
A slightly different version —
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2].';
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma.^2 - x./b)
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
legend("\gamma = "+string(gamma), 'Location','best')
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Gamma Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!