Data.png
Hi Everyone, I'm new to Matlab, Please help me. Much Appreciated.
I struggling with Matlab, ok i got almost more than 1 million of data, 1 (first column) refers to number of cycle, (2nd column) -360 to + 360 refers to crank angle, (3rd column) refers to pressure data.
I need to rearrange the data so that i got
column 1: crank angle
column 2: pressure data for cycle 1 ( referring to angle in column 1)
column 3: pressure data for cycle 2
and so on till cycle 143

5 件のコメント

John D'Errico
John D'Errico 2019 年 3 月 15 日
This is not an indexing problem at all. Just learn how to use reshape.
However, if your result will not have the same number of elements in each cycle, then you will need to split them into cells of a cell array, since a regular array must contain the same number of elements in every row and column.
madhan ravi
madhan ravi 2019 年 3 月 15 日
Agree with John D'Errico , in addition to that please share your data and write explicitly show how your desired output should look like.
Jafnii Jalaludin
Jafnii Jalaludin 2019 年 3 月 15 日
I dont really understand, could u guide me to a tutorial/ solution that related to my problem?
John D'Errico
John D'Errico 2019 年 3 月 15 日
Read the help for reshape. More importantly, I would suggest you are still thinking as if you are using a spreadsheet. So what you need most is to read the getting started tutorials. Actually spend some time learning to use MATLAB. Reshape is a basic tool that you will find in the very beginning. Otherwise, you will be asking basic questions at every opportunity, but still thinking in terms of a spreadsheet.
Jafnii Jalaludin
Jafnii Jalaludin 2019 年 3 月 15 日
編集済み: Stephen23 2019 年 3 月 15 日
@madhanravi i have attached how i want the output, i cant share the data since it is too large.
So in order to get like in the picture, i need to learn on reshaping?

サインインしてコメントする。

 採用された回答

Stephan
Stephan 2019 年 3 月 15 日
編集済み: Stephan 2019 年 3 月 15 日

0 投票

Hi,
as suggested in the comments read the documentation. Here is a small example which is near by your problem. Try to understand what happens by reading and by adapting this to your problem:
% Building a small example
A = repelem([1 2 3]',5,1);
A(:,2) = repmat((-2:2)',3,1);
A(:,3) = rand(15,1) + 1
% Reshaping the way you want it
B = [A(1:sum(A(:,1)==1),2), reshape(A(:,3),sum(A(:,1)==1),[])]
Best regards
Stephan

1 件のコメント

Jafnii Jalaludin
Jafnii Jalaludin 2019 年 3 月 19 日
Thanks Stephan ! Much Appreciated.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by