1×0 empty double row vector with command find

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

Answers (1)

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)))

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Products

Asked:

on 3 May 2021

Answered:

Jan
on 3 May 2021

Community Treasure Hunt

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

Start Hunting!