Code doesn't display outputs correctly
Show older comments
Below shows the code that I'm working on.
function [PF1, PF2]=CPF(xi,eta,xk,yk,nkx,nky,L)
A=L^2;
B=2*L*(-nky*(xk-xi)+nkx*(yk-eta));
E=(xk-xi)^2+(yk-eta)^2;
D=sqrt(abs(4*A*E-(B^2)));
BA=B/A;
EA=E/A;
if (D<0.0000000001)
PF1=0.5*L*log(L)+(1+0.5*BA)*(log(abs(1+0.5*BA)))-0.5*BA*log(abs(0.5*BA))-1;
PF2=0;
else
PF1=0.25*L*(2*log(L)-1)-0.5*BA*log(abs(EA))+(1+0.5*BA)*log(abs(1+BA+EA))+(D/A)*(atan((2*A+B)/D));
PF2=L*(nkx*(xk-xi)+nky*(yk-eta))/D*(atan((2*A+B)/D)-atan(B/D));
sprintf('\n\t%f %f\n\n',PF1,PF2);
end
Upon calling the function in Command Window, the output given is:
>>CPF(xi,eta,xk,yk,nkx,nky,L)
PF1 is 11.248000. PF2 is 27.763502
ans =
11.2480
I like to check if there's a way to either remove the "ans = 11.2480" line or have the ans show the 2nd value which is 27.76...
Any help will be appreciated. Thanks!
1 Comment
Priyank Upadhyaya
on 1 Oct 2012
When you call CPF(xi,eta,xk,yk,nkx,nky,L); use a semicolon in the end that will remove the ans = 11.24.
Accepted Answer
More Answers (0)
Categories
Find more on App Building 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!