How to make plot of an equation?

1 view (last 30 days)
THT
THT on 3 Jan 2022
Edited: KSSV on 3 Jan 2022
I want to plot the equation with E in x-axis and n in y-axis:
And here is my code and the respond:
E = linspace(-10,10,0.1);
n = @(E, r1, h_, Vf) ((E.^2)+r1*E.)/(2*pi*h_*h_*Vf*Vf);
r1 = 0.4;
h_ = 6.62607004*10^-34;
Vf = 10^6;
plot(E,n);
File: Q5_d.m Line: 3 Column: 35
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
How to fix it?

Accepted Answer

KSSV
KSSV on 3 Jan 2022
Edited: KSSV on 3 Jan 2022
You messed up with linspace and the defined function.
E = -10:0.1:10 ;
r1 = 0.4;
h_ = 6.62607004*10^-34;
Vf = 10^6;
n = (E.^2+r1*E)./(2*pi*h_*h_*Vf*Vf);
plot(E,n);
If you want to make a function like yours:
E = linspace(-10,10,100);
n = @(E, r1, h_, Vf) ((E.^2)+r1*E)./(2*pi*h_*h_*Vf*Vf);
r1 = 0.4;
h_ = 6.62607004*10^-34;
Vf = 10^6;
plot(E,n(E,r1,h_,Vf));

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!