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

조회 수: 3 (최근 30일)
Nicholas
Nicholas 2014년 9월 22일
편집: Nicholas 2014년 9월 22일
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