フィルターのクリア

Variable definition

1 回表示 (過去 30 日間)
Hide
Hide 2011 年 7 月 28 日
It is assumed there are 20000 values in a row.(as csv file)
I use "load" command, I can define new variable include all data. But I want to define variables that using partially data.
For example, data from No.1 to No.100 as variable "val_1", and data from No.101 to 200 as variable "val_2", .....and data from No.19901 to No.20000 as "val_200".
Can you tell me how to write the MATLAB code? Thank you.
  1 件のコメント
Hide
Hide 2011 年 7 月 28 日
Thank you very much for your exact answer.
I can solve one of my problem.
When new problem is occur, I hope your teaching.
And I'm sorry for my bad English skills.
Thank you very much.

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

採用された回答

Rick Rosson
Rick Rosson 2011 年 7 月 28 日
  1. Instead of having 200 separate variables, it might be easier to create a single variable containing the 20,000 values arranged as a 2D matrix, consisting of 100 rows x 200 columns (or vice versa). This arrangement of your data will make it much easier to analyze and visualize the data in MATLAB, which is inherently based on vectors and matrices.
  2. Also, you may want to consider using the csvread function instead of the load function to read the data in from your CSV file.
Please try the following:
filename = 'myfile.csv';
X = csvread(filename);
Y = reshape(X,100,200);
Now you can access any one of the 200 columns of data as follows:
k = 40; % select a particular column k
V = Y(:,k); % all rows for the k-th column
HTH.
Best, Rick
  1 件のコメント
Hide
Hide 2011 年 7 月 28 日
Thank you very much for your exact answer.
I can solve one of my problem.
When new problem is occur, I hope your teaching.
And I'm sorry for my bad English skills.
Thank you very much.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by