How to plot certain columns from a complex matrix

조회 수: 1 (최근 30일)
Avery
Avery 2023년 7월 28일
답변: Daniel 2023년 7월 29일
I have a txt file and I turned it into a matrix, I then want to plot certain columns and make comparisons. Within the matrix there are 5 types of angles from two different systems, each with angles from the x, y, z plane. I want to select a type of angle and then put the two systems next to each other with their 3 angles, so there should be 6 angles on one graph. How would I do that?
  댓글 수: 3
Avery
Avery 2023년 7월 28일
Here is the txt file. The various angle types are at the top: ex. LHipAngles, LKneeAngles, etc
dpb
dpb 2023년 7월 28일
Whassup w/ all the repeated text at the beginning? Can't you clean it up some first? Pretty tough to decipher that mess w/o knowing what it all is at the beginning. How did you get such a mess?

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

답변 (1개)

Daniel
Daniel 2023년 7월 29일
Assuming that your data input is a simple matrix of double, then:
  1. Determine the columns you want to plot. Since I'm assuming your data input is a matrix, you should be able to count columns in the text file. (MATLAB is 1-based, so the first column is column 1.)
  2. plot(data(:,[column1 column2 column3 column4 column5 column6]))
  3. legend('Entry 1','Entry 2','Entry 3','Entry 4','Entry 5','Entry 6')
Example below.
data = rand(100,10)+[1:10];
plot(data(:,[1 3 5 7 9 2]))
legend('Random entries 1','Random entries 3','5','7','9','2')
If that doesn't work on your input data, then please share the commands you're using to import your data, and/or the data type. You can get the data type with the class command, e.g.
class(data)
ans = 'double'
My data is simple numbers so it has the underlying data type double, but there are quite a few different ways you can import data, with different resulting data types.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by