creating new matrix based on column value

I have a data file that is 3 columns (Density, Temp, Pressure)
I generate the data using C++ and it loop through all possible density and temperatures to calculate a pressure. The issue is I want to connect the lines of Density vs. Pressure at a given temp (isotherms). Is there a way to do this in MATLAB? Alternatively, is there a way to create a new matrix that has Density in the first column, and the pressure at a given temp is in column 2, and when temp changes from original matrix, it creates a new column at the next given temp.
The current structure:
Density Temp. Pressure
1 300 1
2 300 1.1
...
4 300 1.2
1 400 1.05
2 400 1.12
...
4 400 1.23
So it would take this matrix that I already have and create a new one that looks like this:
Density Pressure(@300 K) Pressure(@400 K) etc...
1 1 1.05 ...
2 1.1 1.12 ...
...
4 1.2 1.23 ...

Antworten (1)

madhan ravi
madhan ravi am 5 Nov. 2018
Bearbeitet: madhan ravi am 5 Nov. 2018

0 Stimmen

have a look at readtable() and tables()

4 Kommentare

Benjamin
Benjamin am 5 Nov. 2018
Bearbeitet: Benjamin am 5 Nov. 2018
If I use readtable(), it just reads the data in the same way. If I have a column, A that is 465x1, why can a not do:
B = reshape(A,[31,15]);
This would do what I think I want, but it says the number of elements must not change. 31*15 = 465 though
madhan ravi
madhan ravi am 5 Nov. 2018
Bearbeitet: madhan ravi am 5 Nov. 2018
give rather simple explanation I'm having difficulty understanding your question
A=rand(465,1);
reshape(A,31,15)
madhan ravi
madhan ravi am 5 Nov. 2018
See the above comment

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 5 Nov. 2018

Kommentiert:

am 5 Nov. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by