Creating new matrix from the second column of other matrices

1 回表示 (過去 30 日間)
Shabnam M
Shabnam M 2019 年 7 月 22 日
コメント済み: Shabnam M 2019 年 7 月 23 日
Hi,
I have 10918 matrices with dimensions of [1000*4].
I want to create a new matrix which its columns are the second column of 10918 matrices which I have.
These 10918 matrices are .plt file and their name are as : PIV_1, PIV_2, PIV_3,....,PIV_10918.
For example:
PIV_1=[x_1,y_1,u_1,v_1]
PIV_2=[x_2,y_2,u_2,v_2]
...
PIV_10918=[x_10918,y_10918,u_10918,v_10918]
new matrix=[y_1,y_2,...,y_10918]
I am sorry if i cant explain well . Thanks in advance for your help.
  2 件のコメント
Stephen23
Stephen23 2019 年 7 月 22 日
"These 10918 matrices are .plt file and their name are as : PIV_1, PIV_2, PIV_3,....,PIV_10918."
The most important question: How did you get so many individually-named variables in the workspace?
Note that using numbered variables is a sign that you are doing something wrong. Your code design forces you to write slow, complex, inefficient, obfuscated, buggy code that is hard to debug. Read this to know some reasons why:
Most likely you could have easily avoid this by using indexing. Indexing is simple, neat, and very efficient (unlike what you are trying to do).
Shabnam M
Shabnam M 2019 年 7 月 23 日
These matrices are some data from experimental analysis for different time step, and I need to find a matrix which its columns are the second column of those 10918 matrices.
Thanks for your suggestion, I will read the indexing to find a way.

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

回答 (1 件)

Torsten
Torsten 2019 年 7 月 22 日
編集済み: Torsten 2019 年 7 月 22 日
new_matrix = [PIV_1(:,2),PIV_2(:,2),...,PIV_10918(:,2)]
Quite much to write ...
You should have worked with one 10918x1000x4 matrix PIV with PIV(i,:,:) = PIV_i.

カテゴリ

Help Center および File ExchangeFluid Dynamics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by