How to include variables in an expression while plotting?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
For example
Nth=10^(15+20log10(f))*Nthoff
if i have to plot this expression and the 'Nthoff' value is unknown! how to plot expressions like this if few variable values in the expressions are unknown.
Réponses (1)
Rik
le 15 Fév 2017
In this case, you don't really need to know Nthoff, as it is only a factor, so you can plot this while setting Nthoff=1;
Usually, you would have a range of values that a parameter is expected to have, then you could use either a for-loop to plot a few manually chosen different values, or you can use a vectorized (in this case a matrix-ized) solution. Because there is no way for Matlab to predict the behavior of your function without the range of possible values, it will not be able to plot the shape of the general solution (except in cases like yours).
f=linspace(0,7,130)';%make sure it is a col-vector
Nthoff=1:4;%make sure it is a row-vector
Nth=repmat(10.^(15+20*log10(f)),1,length(Nthoff)).*repmat(Nthoff,length(f),1);
plot(f,Nth)
Or in a loop:
f=linspace(0,7,130)';%make sure it is a col-vector
Nthoff=1:4;%make sure it is a row-vector
for n=Nthoff
Nth=10.^(15+20*log10(f))*n;
plot(f,Nth),hold on
end
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!