the error of not enough input arguments

7 views (last 30 days)
ayman elashmawy
ayman elashmawy on 7 Jun 2019
Edited: John D'Errico on 9 Jun 2019
Hello,
i am trying to run the below code , but it gives me the error of not enough input arguments
can anyone help me
thanks in advance
the code is:
d1= 1545e-9:1e-9:1548e-9;
d2= 1548e-9:0.1e-9:1557e-9;
d3= 1557e-9:1e-9:1575e-9;
d=[d1 d2 d3];
o=b(2,:);
% the begin of apodized DFB
is=length(d);
l=40e-3;
no=1e-5;
pi=22/7;
a=4*log(2);
e=l/ii;
for i1=1:is
i1
x(i1)=9.19.*( (1/d(i1))-(1e9/1550));
k(i1)=@(z) (pi/d(i1)).*no.*exp(-a.*((z-(l/2))/l).^2);
kt=(pi/1550e-9)*no;
g= 0.98*(4*kt*exp(-kt*l)+0.15);
q(i1)=sqrt(((g-(1j*x(i1)).^(2))+(k(i1).^2)));
dfdz(i1)=@(z,f) [ (1j.*k(i1)).*(f(2))-((g-(1j.*x(i1))).*f(1)); ( -1j.*k(i1).*(f(1)))+((g-(1j.*x(i1))).*f(2)) ];
bc2(i1)=@(fa,fb)[ fa(1)-o(i1); fb(2) ];
finit(i1)=@(z)[((-1j./k(i1)).*((q(i1).*(((k(i1).*o(i1))./(x(i1).*tanh(l.*q(i1)) + (g.*tanh(l.*q(i1)).*1j) - q(i1).*1j).*cosh((q(i1).*z))+(-(k(i1).*o(i1).*tanh(l.*q(i1)))./(x(i1).*tanh(l.*q(i1)) + g.*tanh(l*q(i1))*1j - q(i1).*1j).*sinh((q(i1).*z)))))+((g-(1j.*x(i1))).*((-(k(i1).*o(i1).*tanh(l.*q(i1)))./(x(i1).*tanh(l.*q(i1)) + g.*tanh(l.*q(i1)).*1j - (q(i1).*1j)).*cosh(q(i1).*z)+((k(i1).*o(i1))./(x(i1).*tanh(l.*q(i1)) + g.*tanh(l.*q(i1)).*1j - q(i1).*1j).*sinh(q(i1).*z))))))));(-(k(i1).*o(i1).*tanh(l.*q(i1)))./(x(i1).*tanh(l.*q(i1)) + g.*tanh(l.*q(i1))*1j - q(i1).*1j).*cosh(q(i1).*z))+((k(i1).*o(i1))./(x(i1).*tanh(l.*q(i1)) + (g.*tanh(l.*q(i1)).*1j) - (q(i1).*1j)).*sinh(q(i1).*z))];
dbstop if error
solinit2(i1)=bvpinit(linspace(0,l),finit(i1));
sol2(i1)=bvp4c(dfdz(i1),bc2(i1),solinit2(i1));
idx2= e:e:l;
u(:,i1)=deval(sol2(i1),idx2(i1));
delta2(i1)=l.*x(i1);
diff2(i1)=d(i1)-(1550e-9);
end
  8 Comments
John D'Errico
John D'Errico on 9 Jun 2019
Edited: John D'Errico on 9 Jun 2019
We cannot know what problem you arre running into. That is because we have no data to go on, to test your code out.
And Jan is totally correct. Redefining pi to be 22/7 is a terrible idea. pi already exists in MATLAB. There is no need to define it as an incorrect value!!!!!!! All that does is start you out in trouble.
So even though you think the problem is the initial guess, that is not terribly relevant, since we lack any data tto use. How can we possibly know what a good initial guess would be for some totally complicated, problem, one where we see no data to base anything on?
Oh - there is no need to put the line:
dbstop if error
in the middle of your code. That will only slow it down. You can set dbstop ONCE if you want it turned on, before you ever run the code. That is entirely sufficient. But if your code is not generating errors, then it won't generate errors, and therefore, having dbstop turned on at all will only slow your code down.
Another obvious error:
e=l/ii;
You use the variable ii but it is never defined.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements 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!