Converting these mathematical formulas to a matlab equation.

How can i convert these to a proper matlab equation?
v0=25;
theta1= 30;
y0=3.5;
d1=(v0.*cos(theta1).*(v0.*sin(theta1)+ sqrt((v0.*sin(theta1)).^2 + 2.*9.81.*y0)))/9.81
y1=(x1.*tan(theta1))-((1/2).*((9.81.*(x1)^.2)/((v0.*cos(theta1))^.2))) +y0
But
I spend a lot of time to write it but it doesn't work. Thank you.

 Accepted Answer

(x1)^.2
You probably didn't mean to raise a square matrix x1 to the 0.2 power here for two reasons.
By the way, cos isn't quite the correct function to use. It computes the cosine of an angle in radians. But the "See Also" section on its documentation page (doc cos) lists the correct function to use for your problem.

3 Comments

thanks a lot for your time. I can't fix this ..
v0=25;
theta1=30;
y0=3.5;
d1=(v0.*cosd(theta1).*(v0.*sind(theta1)+ sqrt((v0.*sind(theta1)).^2 + 2.*9.81.*y0)))/9.81
x1=linspace(0,d1,200)
y1=((x1.*tand(theta1))-((1/2).*((9.81.*(x1).^2)/((v0.*cosd(theta1)).^2))) +y0)
Apparently the author of the problem wanted you to work with column vectors of data for your X and Y rather than row vectors. Transpose x1.
x1 = linspace(0, d1, 200).';
By the way you've written the code, y1 will be the same size as x1 so changing x1's size will also change y1.
I'd also recommend ending your lines with semicolons to suppress the display unless you specifically want to see the results (to check your work, for instance.)

Sign in to comment.

More Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!