I have 62 Files each consisting of 300 rows and 4 columns.
The 1st and 2nd Columns Are The X-Coordinates (x1,x2)
The 3rd and 4th Columns Are The Y-Coordinates (y1,y2)
For each file I would like to do the following:
- Calculate: Opp = (x1-x2);
- Calculate: Adj =( y1-y2);
- Calculate: Angle_Deg = atand(Opp ./ Adj);
- Calculate: AvgAngle_Deg = mean(Angle_Deg);
- Calculate the Velocity: V = ((tand(AvgAngle_Deg)*10*cosd(30)-10*sind(30));
How would I code this so that I get 62 separate results that I can plot onto a graph?

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 4월 18일

0 개 추천

You have two general options.
  1. Place all your code for a single file into a for loop that will loop through each of your 62 files. Use "hold on" to add additional lines to your plot.
  2. Create an array for each variable you want to plot. Place the results from each file into a single column. Once completed for all files, call the plot command using the X and Y arrays. Each column will be treated as a separate series. However, this approach will only work if you have the same number of values in your plot variables for every file.

댓글 수: 5

Stephen23
Stephen23 2020년 4월 18일
"However, this approach will only work if you have the same number of values in your plot variables for every file"
Not necessarily: preallocate that array using nan(...) and fill the required numbered of elements per column.
SkyRider44
SkyRider44 2020년 4월 18일
would you be able to write the code?
Cris LaPierre
Cris LaPierre 2020년 4월 18일
I could, but this is your assignment, not mine.
SkyRider44
SkyRider44 2020년 4월 18일
편집: SkyRider44 2020년 4월 18일
Would it be possible if you could write a psuedo code for it? so that i can see how to structure it
Cris LaPierre
Cris LaPierre 2020년 4월 18일
I kind of did already.
Combine what you've already done with what is shown on this page.

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

카테고리

도움말 센터File Exchange에서 Data Types에 대해 자세히 알아보기

질문:

2020년 4월 18일

댓글:

2020년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by