Error using plot Vectors must be the same length.
이전 댓글 표시
Cada vez que corró este código obtengo este error Error using plot Vectors must be the same length., he intentado de todo pero no sé cuál es el problema.
close all
clear
clc
%%
L=1.2;
l=0:0.175:0.8;
W=200;
a=1;
w=W/a^2*l;
DX=0.0001;
%%
for l = 0.1:0.175:0.8
w=(W/((a^2)*l))*a;
B_y=((w*a)*(L/2)*0.4)/0.8;
A_y=((w*a)*(L/2))-B_y;
end
%%
for l = 0:0.175:0.8
x1= 0:DX:(((0.8-l)/2)+0.2);
n1= length(x1);
x2= (((0.8-l)/2)+0.2):DX:(0.6+(l/2));
n2= length(x2);
x3= (0.6+(l/2)):DX:(1.2);
n3= length(x3);
V1= A_y;
M1= A_y*(x1-0.2);
V2=A_y-(w*a*(x2-0.6));
M2=A_y*(x2-0.2)-(w*a((x2-0.6).^2)/2);
V3= A_y+B_y-(w*a*(x3-0.6));
M3= A_y*(x3-0.2)+B_y*(x3-1)-(w*a*((x3-0.6).^2)/2);
%%grafica son los limites
x= [x1, x2, x3];
V= [V1, V2, V3];
M= [M1, M2, M3];
%% graficar
figure(1)
plot(x,V)
title("CORTANTE")
xlabel("x(m)")
ylabel("V(N)")
grid on
figure(2)
plot(x,M)
title("MOMENTO")
xlabel("x(m)")
ylabel("M(N*m)")
grid on
end
댓글 수: 2
KSSV
2020년 11월 2일
You need to rethink on your code...you have messed up at lot of places...What exactly you are trying to plot?
Esteban Rodriguez Daza
2020년 11월 2일
답변 (1개)
Kiran Felix Robert
2020년 11월 5일
0 개 추천
Hi Esteban,
The plot function works only when the input arguments X and Y have identical dimensions.
In your code, when you try to plot ‘x’ and ‘V’ in line 39, the size of x is [1,12002] and size of V is [1,6002], this throws an error.
To plot x vs M, remove the line 39 to line 45, this will work as ‘x’ has same size as ‘M’
Check your code for variables to have identical dimensions before plotting.
Kiran Felix Robert
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!