not enough input arguments in function. Cannot get any output at all
1 view (last 30 days)
Show older comments
function yp = equationb(t, y)
A=2.69; B=168; C=6270; D=59900; %coefficients
V = 10:50;
E= 15000000000; h = 0.048; I = (1/12)*h^4; l=4; rho=1600;
m = 0.177; c = 0.77; k = (48*E*I)/l^3; R = (0.5*rho*h);
yp (1) = y(2);
yp (2,1) = (R/m)*(A*V*y(2).^2 - (B*y(2).^4)/V + (C*y(2).^6)/V^3 - (D*y(2).^8)/V^5) - (c/m)*y(2) - (k/m)*y(1);
end
And my main function is
close all; clear all; clc;
% Initial Conditions
h = 0.048; %section width (m)
x0 = [h,10*h]; %initial displacements
v0 = zeros(length(x0)); %inital velocity
V = 10:50; %flow velocity (m/s)
timespan = [0 30];
for j=1:length(x0)
for k=1:length(V)
a = [x0(1,j), v0(1,1), V(k)];
[t,y] = ode15s(@equationb, timespan, a);
R = find(t>25); %returns a vector containing the linear indices of each nonzero element in array.
LCO = y(R,1);
maximum_amplitude(j,k) = max(LCO);
end
end
figure(1)
hold on; grid on; box on;
ylabel('Structural Displacement Amplitutde (m)')
xlabel('Air Flow Velocity (m/s)')
plot(V,maximum_amplitude(1,:),'go')
plot(V,maximum_amplitude(2,:),'r+')
axis([V(1) V(end) 0 0.7])
6 Comments
Star Strider
on 18 Jan 2016
That depends on what ‘V’ is in your calculation. What are you doing with it?
Accepted Answer
Star Strider
on 18 Jan 2016
This is one possible approach:
function yp = equationb(t, y, V)
Eliminate the vector definition of ‘V’ within ‘equationb’.
Change the call to ‘equationb’ to:
a = [x0(1,j), v0(1,1)];
[t,y] = ode15s(@(t,y)equationb(t,y,V(k)), timespan, a);
and see if that does what you want. (Having 3 initial conditions with a function that returns two derivatives will likely throw an error anyway. This should at least avoid that problem.)
8 Comments
More Answers (0)
See Also
Categories
Find more on Historical Contests 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!