Set functions, returned "too many input arguments"
Show older comments
I'm working on a worksheet for an aerodynamics class. It's not graded, but it helps with the next project. I'm attempting to calculate the graph of the pressure coefficient (c_p) for a given x/c using a theory in class. I have completed the derivations, but when I attempt to create the functions and solve them, MATLAB produces an error message: "Error using codename>@(x,y,b)ln((sqrt(x^2+(y-(b/2))^2)+(y-(b/2)))/(sqrt(x^2+(y+(b/2))^2)+(y+(b/2)))) Too many input arguments."
How would I fix this and get my code to run? I have attached the code below:
clear;
clc;
delta = 0.05;
c = 1;
b = 2;
x = 0:0.1:1;
y = 0:0.1:1;
z = 0;
u_inf = 10;
%incompressible pressure coefficient
fun1 = @(x,y,b) ln((sqrt(x^2 + (y-(b/2))^2)+(y-(b/2)))/(sqrt(x^2 + (y+(b/2))^2)+(y+(b/2))));
fun2 = @(x,y,b) ln((sqrt((x-(c/2))^2 + (y-(b/2))^2)+(y-(b/2)))/(sqrt((x-(c/2))^2 + (y+(b/2))^2)+(y+(b/2))));
fun3 = @(x,y,b) ln((sqrt((x-c)^2 + (y-(b/2))^2)+(y-(b/2)))/(sqrt((x-c)^2 + (y+(b/2))^2)+(y+(b/2))));
xc = (0:.01:1);
cpi = @(x,y,b) -delta/pi.*(fun1(x,y,0,b) - 2*fun2(x,y,.5,b) + fun3(x,y,1,b) );
plot(xc,cpi(xc,0,b));
%compressible
%M < 1
funa = @(x,y,z,u_inf,c,delta,y0) (u_inf*delta)/sqrt(((x-c).^2)+(y-y0).^2+z.^2);
funb = @(x,y,z,u_inf,c,delta,y0) -(u_inf*delta)/sqrt(x.^2+(y-y0).^2+z.^2);
func = @(x,y,z,u_inf,c,delta,y0) (-2*u_inf*delta)/sqrt(((x-c).^2)+(y-y0).^2+z.^2);
fund = @(x,y,z,u_inf,c,delta,y0) (-2*u_inf*delta)/sqrt(((x-(c/2)).^2)+(y-y0).^2+z.^2);
ua = integral(@(y0) funa(x,y,z,u_inf,c,delta),-b/2,b/2) - integral(@(y0) funb(x,y,z,u_inf,c,delta),-b/2,b/2);
ub = integral(@(y0) func(x,y,z,u_inf,c,delta),-b/2,b/2) - integral(@(y0) fund(x,y,z,u_inf,c,delta),-b/2,b/2);
u_tot = (1/(2*pi))*(ua + ub);
M = 0.6;
bet = sqrt(1-M^2);
cpc = @(x,y) cpi(x,y*bet,b*bet)/bet;
hold on
plot(xc,cpc(xc,0))
set(gca,'ydir','reverse')
xlabel('x/c')
ylabel('c_p')
Accepted Answer
More Answers (0)
Categories
Find more on Programming 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!