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

2 次查看(过去 30 天)
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 个评论
Nicholas
Nicholas 2014-9-22
编辑:Nicholas 2014-9-22
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by