what does this Complex values are not supported mean?
조회 수: 11 (최근 30일)
이전 댓글 표시
errors in line 35 "xlim([min(tetagrados) max(tetagrados)])"
clear variables
clc
close all
MasaCarga = 400;
M = MasaCarga/2;
L = 1.4;
L1 = 0.5;
L2 = 1;
a = 0.8;
b = 2.5;
g = 9.8;
teta1 = acos((b-L1)/L);
teta2 = acos((b-L2)/L);
nDivisiones = 100;
teta = linspace(teta1,teta2,nDivisiones);
N = M*g*a./(L*cos(teta));
Ey = M*g*a./(L*cos(teta));
Dy = M*g*(1-a./(L*cos(teta)));
Fp = M*g*cot(teta);
Cy = M*g*(1-2*a./(L*cos(teta)));
Cx = -Fp;
Fy = M*g*(1-a./(L*cos(teta)));
Fx = -Fp;
tetagrados = teta*180/pi;
colorazul = [0 0 153]/255;
colorvino = [153 51 102]/255;
plot(tetagrados,Fp,'linewidth',1.2,'displayname','Fuerza F_(p)','color',colorazul);
xlim([min(tetagrados) max(tetagrados)])
xlabel('Angulo \alpha (°)')
ylabel('Fuerza (N)')
hold on
plot(tetagrados,N,'r','linewidth',1.2,'displayname','Fuerza N','color',colorvino);
legend('boxoff')
legend('location','best')
set(gca,'fontsize',13)
figure()
plot(tetagrados,Ey,'linewidth',1.2,'displayname','Fuerza E_y','color',colorazul);
xlim([min(tetagrados) max(tetagrados)])
xlabel('Angulo \alpha (°)')
ylabel('Fuerza (N)')
hold on
plot(tetagrados,Dy,'r','linewidth',1.2,'displayname','Fuerza D_(y)','color',colorvino);
legend('boxoff')
legend('location','best')
set(gca,'fontsize',13)
figure()
plot(tetagrados,Cx,'linewidth',1.2,'displayname','Fuerza C_(x)','color',colorazul);
xlim([min(tetagrados) max(tetagrados)])
xlabel('Angulo \alpha (°)')
ylabel('Fuerza (N)')
hold on
plot(tetagrados,Cy,'r','linewidth',1.2,'displayname','Fuerza C_(y)','color',colorvino);
legend('boxoff')
legend('location','best')
set(gca,'fontsize',13)
댓글 수: 0
채택된 답변
Yazan
2021년 8월 23일
tetagrados is a vector of complex numbers. So, first of all, notice that the function plot throws a warning and plots only the real parts, ignoring the imaginary ones.
Second, in this line
xlim([min(tetagrados) max(tetagrados)])
You are asking Matlab to restrict the limits of the X-axis to the min and max of tetagrados. However, tetagrados is complex, the min and max functions will return complex numbers. How can you set the limits of an axis with complex numbers? You obviously can not. So, you have an error. You should decide to work with the real part, imaginary part, or absolute values.
example:
xlim([min(real(tetagrados)) max(real(tetagrados))])
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!