Need Help Starting Code

조회 수: 4 (최근 30일)
Bailey Smith
Bailey Smith 2018년 6월 23일
댓글: Image Analyst 2018년 6월 24일
So I'm having some trouble planning out how to tackle this problem:
A toy rocket is powered by pressurized water that is discharged from the nozzle at the beginning of the flight.
a. Plot the elevation as a function of time
b. Compute and plot the velocity and acceleration of the rocket as functions of time
c. Write a MATLAB code that will automatically determine the thruster time, the maximum altitude, the maximum velocity, and the maximum acceleration
d. The tip of the rocket transports a 2.7 gram ping-pong ball. Determine the maximum support force for the ball.
I am given data: time (in seconds) and elevation (in meters). My first problem lies in the fact that I have a TON of data. 61 pages worth of data. 2 columns and 3280 rows of data. I know I'll need to preallocate this somehow to make it run efficiently. What help/tips do you have to help me get started and to help me make it run most efficiently?
EDIT: I have m=zeros(3280,2) as my preallocation. I am considering putting the data into a file and trying to pull it, to save space.
UPDATE 1:
rTimeData=fopen('rocket_time_data.txt','r');
formatSpec = '%f';
A = fscanf(rTimeData,formatSpec);
fclose(rTimeData);
rElevData=fopen('rocket_elev_data.txt','r');
formatSpec = '%f';
B=fscanf(rElevData,formatSpec);
fclose(rElevData);
%PART B
vel=sqrt(0^2+2*(9.81)*(B-0));
acc=vel/B;
My acceleration seems to not be right. Should it be a 3280x3280? (Part A plots fine, by the way.)
  댓글 수: 5
dpb
dpb 2018년 6월 24일
What's the units of the elevation data?
If you have distance and time, what's definition of velocity?
Image Analyst
Image Analyst 2018년 6월 24일
2 columns and 3280 rows of data is a microscopic amount of data, NOT "a TON of data". For example, it's like only one two-thousandths (0.05%) the amount of data in an ordinary digital image. It will easily all fit into your computer memory simultaneously.
For what it's worth, I'm attaching my demo of a projectile/trajectory. It computes just about anything one would ever want to know about a projectile.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by