Please explain what this error is...
Show older comments
[Mistakenly put Q? in Title moved to Body by dpb]
Hi, I'm very new to MATLAB and I am having some trouble. Lots of people have had the same problem but nobody seems to be able to explain or solve it in plain English. Could somebody please explain what this error is and how to fix it? I have a simpl...
function [eq1,eq2,eq]= Myfun(a,b)
m0=9.1094e-31;
me=.7*m0;
q=1.60218e-19;
k=1.38064852e-23;
Tc=300;%kelvin
KT=k*Tc;
h_plank=6.626069572929e-34;
hbar=h_plank/(2*pi);
c=3e8;
omega=6.8e-6;
V=1*q;
Ts=5678;
KT2=k*Ts;
ph=h_plank*pi;
hc=h_plank^3*c^2;
filename='am15.txt';
As=importdata(filename);
lambda=As(1,:)*1e-9;
x=h_plank*c./lambda; % x is E
% M(1) is T_H and M(2) is delta_mu
Delta_E=0.01;
Ext_E=1.7;
for iii=1:length(x)
if (Ext_E/2-Delta_E/2) < x(iii) < (Ext_E/2+Delta_E/2)
% if x(iii) >= (Ext_E/2-Delta_E/2) && x(iii) <= (Ext_E/2+Delta_E/2)
tau=1;
elseif x(iii) >= (Ext_E/2+Delta_E/2) || x(iii) <= (Ext_E/2-Delta_E/2)
tau=0;
end
end
eq1=trapz(x,tau*(me*k*a/ph)*log10(1+exp(-(x-b/2)./k*a)));
eq2=trapz(x,tau*(me*KT/ph)*log10(1+exp(-(x-V/2)./KT)));
eq3=trapz(x,(2*omega/hc)*(x.^2./(exp(x/KT2)-1)));
eq4=trapz(x,(2*pi/hc)*(x.^2./(exp((x-b/2)/k*a)-1)));
eq1=(1/(pi*hbar))*(eq1-eq2)-eq3+eq4;
eq11=(trapz(x,tau*(me*k*a/ph)*(x+a*k-b/2).*log10(1+exp(-(x-b/2)./k*a))));
eq22=trapz(x,tau*(me*KT/ph)*((x+KT-V/2)).*log10(1+exp(-(x-V/2)./KT)));
eq33=trapz(x,(2*omega/hc)*(x.^3./(exp(x/KT2)-1)));
eq44=trapz(x,(2*pi/hc)*(x.^3./(exp((x-b/2)./k*a)-1)));
eq2=(1/(pi*hbar))*(eq11-eq22)-eq33+eq44;
eq=[eq1 eq2];
end
when I run this program that matlab shows this error
>> Myfun
Not enough input arguments.
Error in Myfun (line 36)
eq1=trapz(x,tau*(me*k*a/ph)*log10(1+exp(-(x-b/2)./k*a)));
Accepted Answer
More Answers (1)
Your function has to be called with 2 inputs a and b for example when a=2 and b=5:
[res1, res2, res3] = MyFun(2, 5)
1 Comment
Hossein Baglari
on 21 Nov 2020
Categories
Find more on Discrete Fourier and Cosine Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!