Creating variables as needed with arrays

Hello,
I was wondering if there is a way to create matlab variables as needed. I have several sets of data that all have the same amount of columns but different amounts of rows. The amount of rows in each is usually several hundred to several thousand, so creating variable names for each row and saving it in its own array would be tedious. I am trying to use this in conjuction with some of the signal processing apps.
Thank you

4 件のコメント

Rik
Rik 2019 年 3 月 5 日
Can you give a bit more context? Your current question is not clear to me, as you don't need to name rows inside an array.
lus31
lus31 2019 年 3 月 5 日
So I have multiple sets of data that all contain 2000 columns, but vary by numbers of rows. I would like to be able to write some sort of loop that can go through the matrix and store each row as its own array.
Thank you
Kevin Phung
Kevin Phung 2019 年 3 月 5 日
do you know how many sets of data you will have? and how they are stored?
lus31
lus31 2019 年 3 月 5 日
they are stored as csv files, which I import to matlab as tables and then convert to arrays. and total sets no. but i would say under 100

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

回答 (1 件)

Matt J
Matt J 2019 年 3 月 5 日
編集済み: Matt J 2019 年 3 月 5 日

0 投票

Here is an example of how you can split rows of a matrix into separate cells of a cell array,
>> data=rand(3,5)
data =
0.9001 0.3900 0.1140 0.0410 0.7867
0.3637 0.9392 0.7835 0.1848 0.8945
0.5390 0.2387 0.0046 0.3383 0.9172
>> rows=num2cell(data,2)
rows =
3×1 cell array
{1×5 double}
{1×5 double}
{1×5 double}
however, I am puzzled as to why you think breaking the rows into their own arrays would help you. Normally, it is best just to grab the rows as you need them by matrix indexing,
row=data(i,:);

カテゴリ

質問済み:

2019 年 3 月 5 日

編集済み:

2019 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by