I am trying to input my found critical point into the second derivative, but when I double it to get an actual value, I get an array of zeros.

조회 수: 1 (최근 30일)
Q = @(v) sym(v);
Pi = Q(pi);
E = Q(9.9)*10^6;
p = Q(.098);
F = Q(1500);
L = Q(20);
g = Q(32.2)*12;
I = (F*L^2)/(E*Pi^2);
syms R1 t
x = I == (Pi/4)*(((R1+t)^4)-(R1^4));
R = solve(x, R1, 'MaxDegree', 4);
W0 = 2.*Pi.*p.*L.*g.*t.*R;
dW = diff(W0,t)==0;
cp = arrayfun(@(F) vpasolve(F,t), dW(1), 'uniform', 0);
cp{1};
var = double(vpa(vpa(cp{1})));
ddW = diff(dW,t);
ddW_t = subs(ddW, t, var); % Substitute t with the value
number = double(ddW_t);

채택된 답변

Dyuman Joshi
Dyuman Joshi 2024년 2월 29일
"... but when I double it to get an actual value, I get an array of zeros."
That is because dW is defined as an equation, not an expression.
You can change the definition to an expression and get the results accordingly -
Q = @(v) sym(v);
Pi = Q(pi);
E = Q(9.9)*10^6;
p = Q(.098);
F = Q(1500);
L = Q(20);
g = Q(32.2)*12;
I = (F*L^2)/(E*Pi^2);
syms R1 t
x = I == (Pi/4)*(((R1+t)^4)-(R1^4));
R = solve(x, R1, 'MaxDegree', 4);
W0 = 2.*Pi.*p.*L.*g.*t.*R;
%define dW as an expression
dW = diff(W0,t);
cp = arrayfun(@(F) vpasolve(F,t), dW(1), 'uniform', 0)
cp = 1x1 cell array
{[0.13882567791546955545640596714379]}
var = cp{1}
var = 
0.13882567791546955545640596714379
ddW = diff(dW,t)
ddW = 
ddW_t = subs(ddW, t, var) % Substitute t with the value
ddW_t = 
number = double(ddW_t)
number =
1.0e+03 * -8.3670 + 0.0000i -2.9543 + 0.0541i -2.9543 - 0.0541i
  댓글 수: 3
Oliver Ries
Oliver Ries 2024년 3월 5일
Yes, sorry I forgot to respond to this one. It ended up working although I went a completely different direction and instead of doing the second derivative test, I just returned the lowest weight and the corresponding values, because although this ended up working it still only returned one value every time rather than the 3x1 matrix you are showing.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by