Ploting an anonymous function
显示 更早的评论
I an trying to plot this graph :
M_a = mb*g*2 - Cw*rIntegral*y_bar
Cw = 0.5*rho*(v^2)*(1/yr^0.286)*(rb+rt)*(h/2)*0.2 % Wind force constant;
c1 = ((rt-rb)/h)^2;
c2 = ((rt-rb)/h)*rb;
c3 = rb^2;
y = linspace(0,h);
M1 = (y) M_a + 2*Cw((c1/4.286)*(y.^(4.286)) + (2*c2/3.286)*(y.^(3.286)) + (c3/2.286)*(y.^(2.286))) - F_ax*y;
plot(y,M1(y))
and it gives me this error:
M1 = @ (y) + 2*Cw((c1/4.286).*(y.^(4.286)) + (2*c2/3.286).*(y.^(3.286)) + (c3/2.286).*(y.^(2.286))) - F_ax.*y;"
回答(1 个)
Star Strider
2020-10-24
It appears that ‘Cw’ also needs to be an anonymous funciton, however it is absolutely not obvious what variable it supposed to be a function of.
So:
M_a = mb*g*2 - Cw*rIntegral*y_bar
Cw = @(something) 0.5*rho*(v^2)*(1/yr^0.286)*(rb+rt)*(h/2)*0.2 % Wind force constant;
c1 = ((rt-rb)/h)^2;
c2 = ((rt-rb)/h)*rb;
c3 = rb^2;
y = linspace(0,h);
M1 = (y) M_a + 2*Cw((c1/4.286)*(y.^(4.286)) + (2*c2/3.286)*(y.^(3.286)) + (c3/2.286)*(y.^(2.286))) - F_ax*y;
plot(y,M1(y))
It will aso be necessary to vectorise it, since it and ‘M1’ appear to be a functions of a vector. See Array vs. Matrix Operations for details.
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!