How to combine sections from Workspace into a new vector?

2 ビュー (過去 30 日間)
FW
FW 2019 年 4 月 19 日
編集済み: madhan ravi 2019 年 4 月 20 日
I have Matlab 2017b.
1) If we have two vectors A and B, in the workspace (1000x1), each of same dimension. How can one combine certain sections of A and B to form a new vector D (1000x1), by taking desired data of interest from A and B?
Is there a simple way to achieve this?
2) If we have a vector (1000 x 3) in the workspace, how can we define a new variable Z which contains selected data from an ith row to jth row from vector (1000x3)?
Thank you.

採用された回答

madhan ravi
madhan ravi 2019 年 4 月 20 日
編集済み: madhan ravi 2019 年 4 月 20 日
Yes ,simply use basic indexing:
% 1)
D = [A(1:500);B(1:500)] % example
% 2)
ith_row = 400;
jth_row = 700;
Z = matrix(ith_row:jth_row,:) % matrix is of size 1000 X 3
  4 件のコメント
FW
FW 2019 年 4 月 20 日
Thanks. Where will we place the variable name? If we have multiple datasets in the workspace, how will it the data (200:400, 1) command recognize the data set.
madhan ravi
madhan ravi 2019 年 4 月 20 日
編集済み: madhan ravi 2019 年 4 月 20 日
data is the name of the variable that you want to extract. For example if you have variable named Z which is of size 1000 X 3 then
Z(200:400,1)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by