error Conversion to logical from sym is not possible.
显示 更早的评论
i dont know how to solve that error
here is my code
clc;
clear all;
syms k ;
wo= input('write omega node = ');
% 100;
Mm=input('write motorcycle mass = ');
% 200;
Md=input('write diver mass = ');
% 80;
m=Mm+Md;
cp=input('write Cp = ');
% 0.1;
z=input('write zeita = ');
% 0.6;
i=0;
yo=input('wirte y node value = ');
for M=Mm+40:1:m
i=i+1;
f=((sqrt((k*yo)^2+(2*M*z*sqrt(k/M)*wo*yo)^2)/k)...
*(1/sqrt((1-(wo/sqrt(k/M))^2)^2+(2*z*(wo/sqrt(k/M)))^2)))-cp;
K(:,i)=vpa(solve(f));
r=wo/sqrt(k/m);
end
r=wo/sqrt(k/m);
if r>=1
return
end
C=2*m*z*sqrt(K/m);
M=Mm+40:1:m;
figure(1)
plot(M,K);
figure(2)
plot(M,C);
回答(1 个)
Cris LaPierre
2021-1-3
The issue is with this line of code
if r>=1
Your variable r is a symbolic expression made up of symbolic variables. Therefore, this comparison can't be performed.
You would need to use subs to replace your symbolic variables with values, then use double to convert the symbolic variable to a double.
类别
在 帮助中心 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!