MATLAB: How to remove empty matrix : 1 by 0 in the code

empty matrix

function Question2
%UNTITLED Summary of this function goes here

% Detailed explanation goes here

xxx
But my answer is Empty matrix: 1-by-0
I am trying to find the intersection point, but it has an error, I dont know what to do to change it.
Also i did it in a simple way,
function omg
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
x=-3:0.4:5;
y1=(x.^2);
y2=(x.^3)
find(y1==y2)
this codes works fine, but as soon as I put y1=2+(x.^2); it becomes empty matrix again.
Please help me if you can" thank you so much in advance

Best Answer

The values are not exactly equal, at least not at floating-point precision. Here is some code that really zooms on the points that are nearly equal:
c=14;
g=9.8;
v=35;
t=7;
m=60:0.05:70;
y=c*v./(m*9.8);
y1=1-exp(-c*t./m);
figure
hb = plot(m,y,'.');
hold on;
hr = plot(m,y1,'r.');
set([hb hr],'MarkerSize',24)
xlim([63.6495 63.6505])
ylim([0.785545 .785550])
grid on;
xlabel('mass (kg)');
ylabel('y');
legend('y=(c*v)/(m*g)','y=1-exp(-c*t/m)');
If you change your find command to
find(abs(y-y1)<1e-4)
then you will identify the index of these points. Notice that I used a tolerance, rather than strict equality.