Different array size error
古いコメントを表示
%I dont know why does it marks an error on line 52 (it is commented)
clear all;
clc;
g=9.8;
opcion=1;
while opcion ~=0
fprintf('\n\nMenú de opciones');
fprintf('\n\t1. Animacion de tres tiros parabolicos');
fprintf('\n\t2. Determinación de condiciones para alcanzar una distancia dada por el usuario.');
fprintf('\n\t3. Tiro parabólico con parámetros del usuario.' )
fprintf('\n\t0. Salir');
opcion=input('\n\nEscribe tu opcion: ');
area=0;
switch opcion
case 1
Vo=150;
Ang1 = 23;
Ang2 = 24;
Ang3 = 25;
Ai = 5200;
Ang1 = Ang1*3.1416/180;
Ang2 = Ang2*3.1416/180;
Ang3 = Ang3*3.1416/180;
ta = ( ((Vo*sin(Ang1))+(Vo*sin(Ang1))^2+2*Ai*g)^0.5)/g;
tb = ( ((Vo*sin(Ang2))+(Vo*sin(Ang2))^2+2*Ai*g)^0.5)/g;
tc = ( ((Vo*sin(Ang3))+(Vo*sin(Ang3))^2+2*Ai*g)^0.5)/g;
xmax1 = Vo*cos(Ang1)*ta;
xmax2 = Vo*cos(Ang2)*tb;
xmax3 = Vo*cos(Ang2)*tc;
ymax1 = ((Vo*sin(Ang1))^2)/(2*g);
ymax2 = ((Vo*sin(Ang2))^2)/(2*g);
ymax3 = ((Vo*sin(Ang3))^2)/(2*g);
t1 = 0:0.05:ta;
t2 = 0:0.05:tb;
t3 = 0:0.05:tc;
ya = (Vo*sin(Ang1)).*t1-(0.5*g).*(t1.^2)+Ai;
yb = (Vo*sin(Ang2)).*t2-(0.5*g).*(t2.^2)+Ai;
yc = (Vo*sin(Ang3)).*t3-(0.5*g).*(t3.^2)+Ai;
xa = Vo*cos(Ang1).*t1;
xb = Vo*cos(Ang2).*t2;
xc = Vo*cos(Ang3).*t3;
%Marca error por arrays incompatibles :(
y2a = (tan(Ang1).*xa)-(0.5*g/(Vo*cos(Ang1))^2).*(x.^2)+Ai;
y2b = (tan(Ang2).*xb)-(0.5*g/(Vo*cos(Ang2))^2).*(x.^2)+Ai;
y2c = (tan(Ang3).*xc)-(0.5*g/(Vo*cos(Ang3))^2).*(x.^2)+Ai;
%arreglo diferente
for i = 1:0.5:xmax1
y3a= Ai + (tan(Ang1).*i)-(0.5*g/(Vo*cos(Ang1))^2)*(i.^2);
hold on ;
pause(0.01);
I = imread('Ejemplo volcan.jfif');
ha = image(xlim,(ymax1+Ai-ylim),I);
uistack(h,'bottom')
pause(0.1);
plot(i,y3a,'b*','MarkerSize',8,'LineWidth',2)
title('Grafica Y vs t')
xlabel('Distancia')
ylabel('y(m)')
axis([0 xmax1 0 ymax1+Ai]);
end
for i2 = 1:0.5:xmax2
y3b= Ai + (tan(Ang2).*i2)-(0.5*g/(Vo*cos(Ang2))^2)*(i2.^2);
hold on ;
pause(0.01);
I = imread('Ejemplo volcan.jfif');
hb = image(xlim,(ymax2+Ai-ylim),I);
uistack(h,'bottom')
pause(0.1);
plot(i2,y3b,'b*','MarkerSize',8,'LineWidth',2)
title('Grafica Y vs t')
xlabel('Distancia')
ylabel('y(m)')
axis([0 xmax2 0 ymax2+Ai]);
end
for i3 = 1:0.5:xmax3
y3c= Ai + (tan(Ang3).*i3)-(0.5*g/(Vo*cos(Ang3))^2)*(i3.^2);
hold on ;
pause(0.01);
I = imread('Ejemplo volcan.jfif');
hc = image(xlim,(ymax3+Ai-ylim),I);
uistack(h,'bottom')
pause(0.1);
plot(i3,y3c,'b*','MarkerSize',8,'LineWidth',2)
title('Grafica Y vs t')
xlabel('Distancia')
ylabel('y(m)')
axis([0 xmax3 0 ymax3+Ai]);
end
case 2
%casinho dos
case 3
Vo=input("ingrese velocidad inicial: ");
if Vo > 200
Vo = input("ingrese un dato de velocidad valido entre 1 y 200");
end
Ang = input("angulo del proyectil: ");
Ai = input("Altura inicial: ");
Ang = Ang*3.1416/180;
t = ( ((Vo*sin(Ang))+(Vo*sin(Ang))^2+2*Ai*g)^0.5)/g;
xmax = Vo*cos(Ang)*t;
ymax = ((Vo*sin(Ang))^2)/(2*g);
t1 = 0:0.05:t;
y = (Vo*sin(Ang)).*t1-(0.5*g).*(t1.^2)+Ai;
x = Vo*cos(Ang).*t1;
y2 = (tan(Ang).*x)-(0.5*g/(Vo*cos(Ang))^2).*(x.^2)+Ai;
for i = 1:0.5:xmax
y3= Ai + (tan(Ang).*i)-(0.5*g/(Vo*cos(Ang))^2)*(i.^2);
hold on ;
pause(0.01);
I = imread('Ejemplo volcan.jfif');
h = image(xlim,(ymax+Ai-ylim),I);
uistack(h,'bottom')
pause(0.1);
plot(i,y3,'b*','MarkerSize',8,'LineWidth',2)
title('Grafica Y vs t')
xlabel('Distancia')
ylabel('y(m)')
axis([0 xmax 0 ymax+Ai]);
end
otherwise
if opcion~=0
fprintf('\n Opción no valida ingrese otro dato:');
end
end
end
2 件のコメント
Too much code; no way to run it, no idea which line might be 52; didn't post error message, ...
Use the debugger -- set
dbstop if error
Valente
2022 年 10 月 14 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!