1×0 empty double row vector with command find

6 vues (au cours des 30 derniers jours)
Cris Sanchez
Cris Sanchez le 3 Mai 2021
Réponse apportée : Jan le 3 Mai 2021
Hi everyone, I am trying to find the intersections points in the figure, but when I use the command find I just get this error:
1×0 empty double row vector
This is my code
Vo1=50;
Vo2=80;
g=-9.81;
t_v=0:0.1:20;
h_1=Vo1*t_v+(g*t_v.^2)/2;
h_2=Vo2*(t_v-2)+(g*(t_v-2).^2/2);
figure
plot(t_v,h_1,'m',t_v,h_2,'b') ;
grid on;
title('Trayectorias');
xlabel('Tiempo');
ylabel('Altura');
axis([0 10 0 340]);
legend('Velocidad 50','Velocidad 80','fontsize',14);
find(h_1==h_2)
thanks

Réponses (1)

Jan
Jan le 3 Mai 2021
Why do you call this an "error"? The vectors h_1 and h_2 do not have an equal element at the same location. h_1==h_2 is an elementwise comparison, which relplies a vactor. Do you want to compare all elements with eachother? Then you need:
find(h_1 == h_2.')
Even then it is not expected, that you find identical elements due to the rounding errors. You need a tolerance:
find(abs(h_1 - h_2.') < 10 * eps(max(h_1, h_2)))

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by