plotting a function with different constant values without specifying the variable

Hello, I am trying to plot the Boltzmann Distribution function with different temperatures in the same graph without specifying the variable. Here, the variable of the function is velocity (v), and the others are constant. Please help me with your suggestions.
Thank you in advance
syms f(v)
m = 2.32*10^-26;
kb = 1.38*10^-23;
T = [77 293 393 1273 2273];
for i = i:length(T)
f = sqrt(m/(2*pi*kb*T(i)))*exp(-1*m*v^2/(2*kb*T(i)));
end
ezplot(f)

 Accepted Answer

I have no idea what range of values ‘v’ is supposed to have here, however ezsurf (or fsurf) may be appropriate —
syms v T
m = 2.32E-26;
kb = 1.38E-23;
Tv = [77 293 393 1273 2273];
% for i = i:length(T)
f(T,v) = sqrt(m/(2*pi*kb*T))*exp(-1*m*v^2/(2*kb*T));
% end
figure
ezsurf(f,[Tv(1) Tv(end) 0 1000])
Experiment to get different results.
.

4 Comments

Thank you for your response
what I am looking for is that the T here is constant so the f is only a function of variable v, which has no specific range of values. Therefore, the plot should be between f and v only, not in 3D plot.
O.K.
That was not obvious.
syms v T
m = 2.32E-26;
kb = 1.38E-23;
Tv = [77 293 393 1273 2273];
% for i = i:length(T)
f(v,T) = sqrt(m/(2*pi*kb*T))*exp(-1*m*v^2/(2*kb*T));
% end
NrSp = numel(Tv);
figure
for k = 1:NrSp
subplot(NrSp,1,k)
ezplot(f(v,Tv(k)),[0 500])
grid
title(sprintf('T = %4d',Tv(k)))
% ylim([0 2])
end
Experiment to get different results.
.
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!