フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Obtain specific dimension from multidimensional Arrays

1 回表示 (過去 30 日間)
Ali Tawfik
Ali Tawfik 2020 年 5 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi All,
I am trying to create a new variables based on multidimensional array obtained, for the simplicity I just got the part of the code, I wanna do.
I just want to obtained only the dimension with different values :
For example: s(:,:,1), s(:,:,3), s(:,:,5).. the point is sometimes these values change so I would like to do it with a for a loop or whatever so whatever the dimension number .. I just want the new values with only the different numbers!!
Any help!!
clear all;
clc;
s(:,:,1)=[10;20;30];
s(:,:,2)=[10;20;30];
s(:,:,3)=[100;200;300];
s(:,:,4)=[10;20;30];
s(:,:,5)=[50;60;70];
s(:,:,6)=[10;20;30];
for i=1:2
s_new(:,:,i)=s(:,:,i)
end

回答 (1 件)

James Tursa
James Tursa 2020 年 5 月 12 日
Not really sure what you are asking, but if you only want to pick off some indexes from an arbitrary dimension, simply supply them as a range or vector of indexes. E.g.,
s_new = s(:,:,1:2)
or
s_new = s(:,:,[1 2])
  1 件のコメント
Ali Tawfik
Ali Tawfik 2020 年 5 月 12 日
Thanks for your prompt reply.
But I am talking if I would do this automatically ?
I mean If i have an arbitrary dimension, so can not I just pick ooff the indexes which have different number ?

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by