what does this Complex values are not supported mean?

13 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

Yazan
Yazan el 23 de Ag. de 2021
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))])

Más respuestas (0)

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by