Creating a MATLAB Plot with a varying variables?
44 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey guys,
I have been asked by my organization to make a plot of the function y= x^m on MATLAB. I essentially have to use Matlab to plot the function f(x) = x^m for m = 1,2,3, and 4 on the same figure, as x runs from 1 to 2.
This is what I have so far:
clear all;
close all;
m= 1:1:4;
x=1:0.1:2;
y = x.^m;
xlabel ('value of x'); ylabel ( 'function value');
hold on plot(x,y);
However, when I execute the script, it returns the error "Matrix dimensions must match". Anyone know an alternative route?
0 commentaires
Réponses (2)
Matt J
le 20 Sep 2015
Modifié(e) : Matt J
le 20 Sep 2015
x=1:0.1:2;
for m= 1:4;
xy{1,m}=x;
xy{2,m} = x.^m;
end
plot(xy{:});
xlabel ('value of x');
ylabel ('function value');
1 commentaire
Ikenna Okoye
le 28 Nov 2018
I wanted to do something similar, i have an equation for thrust,F_ava, that depends on two variables 'gamma' and 'ex' and has an outputed vector already, could do this to the code?:
for F_ava(1,:)
xy{1,F_ava} = gamma;
xy{2,F_ava} = ex;
xy{3,F_ava} = ((m_dot.*v_e)+ (P_e-P).*(A_t.*ex));
end
plot(xy{:});
xlabel ('Altitude (km)');
ylabel ('Thrust (N)');
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms 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!