New to MATLab, need help using a .txt file on a graph

2 visualizaciones (últimos 30 días)
Nicholas
Nicholas el 22 de Sept. de 2014
Editada: Nicholas el 22 de Sept. de 2014
load PingPongLabFig.txt
g = 9.81;
v0 = 5.1119;
theta = 0;
y0 = 1.37;
t = PingPongFig.txt;
x = v0*cos(theta)*t
y = y0 + v0*sin(theta)-(1/2)*g*t.^2
plot(t, x, 'ro-', 'LineWidth', 2)
plot(t, y, 'bo-', 'LineWidth', 2)
this is my code, I'll attach my .txt file which i am pretty sure is supposed to be my time (t) as well as the .m file that i got the .txt file from.. I am new to MATLab and coding in general so I apologize if my question is unclear.. All of the files except the .txt are from a given .zip file and must be in the same folder to work the initial velocity is 5.1119m/s initial height is 1.37m initial angle is 0 all else on the .fig should be ok
tl;dr this is my code and I don't know why it won't work or even how to get my .txt file to register in the code
  1 comentario
Nicholas
Nicholas el 22 de Sept. de 2014
Editada: Nicholas el 22 de Sept. de 2014
I solved my problem this is what my code looks like for anyone needing future help
clc;
clear;
load 'NameOfTxtFile.txt';
g = Gravity;
v0 = initial Velocity;
theta = Launch Angle from positive X-axis;
y0 = initial Height;
t = NameOfTxtFile(1,:);
x = v0*cos(theta)*t;
y = y0 + v0*sin(theta)-(1/2)*g*t.^2;
plot(t, x, 'color', 'LineWidth', linewidth)
hold on
plot(t, y, 'color', 'LineWidth', linewidth)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by