define an equation and get the variable value after setting the derivative to zero
1 view (last 30 days)
Show older comments
hello
im trying to define a function then derive it and set the derivative to zero to obtain a number then plug the number to the function to get an answer.
i keep getting an error:
Error using symengine
The dimensions do not match.
Error in sym/privBinaryOp (line 937)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 270)
X = privBinaryOp(A, B, 'symobj::mtimes');
Error in Project (line 32)
w(i)=(2*Mp/(l(i)^2))*((2-(solx/l(i)))/((solx/l(i))*(1-(solx/l(i)))));
the code is listed below
clear all;
clc
disp('Answer the following');
b=zeros(1,1);
h=zeros(1,1);
l=zeros(1,4);
YStress=zeros(1,1);
Mp=zeros(1,1);
w=zeros(1,4);
for i=1:1
b(i)=input('Enter the width of this span in inches ');
h(i)=input('Enter the depth of this span in inches ');
YStress(i)=input('Enter the yield stress of this span in ksi ');
Mp(i)=(b*((h/2)^2)*YStress)/12;
end
for i=1:4
disp('Span');
disp(i);
disp(' ');
l(i)=input('Enter the length of this span in feet ');
end
for i=1:4
if i==1
syms f(x);
f(x)=(2*Mp/(l(i)^2))*((2-(x/l(i)))/((x/l(i))*(1-(x/l(i)))));
df=diff(f(x),x);
solx=solve(df==0,x);
w(i)=(2*Mp/(l(i)^2))*((2-(solx/l(i)))/((solx/l(i))*(1-(solx/l(i)))));
elseif i==4
syms f(x);
f(x)=(2*Mp/(l(i)^2))*((2-(x/l(i)))/((x/l(i))*(1-(x/l(i)))));
df=diff(f(x),x);
eqn=df==0;
solx=solve(df==0,x);
w(i)=(2*Mp/(l(i)^2))*((2-(solx/l(i)))/((solx/l(i))*(1-(solx/l(i)))));
else
w(i)=(8*Mp)/(l(i)^2);
end
end
Any help is appreciated
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus 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!