필터 지우기
필터 지우기

Creating a multidimensional array using csv data

조회 수: 6 (최근 30일)
Andrea
Andrea 2015년 9월 15일
댓글: Star Strider 2015년 9월 15일
IM_1 = csvread('filename1.csv',2,2,[2,2,214,8]);
IM_2 = csvread('filename2.csv',2,2,[2,2,206,8]);
IM_data = [IM_1];
IM_data(:,:,2) = [IM_2];
I'm getting an error code for the last line- "Subscripted assignment dimension mismatch". How can I get around this error message? Is my notation wrong for the last two lines?

답변 (1개)

Star Strider
Star Strider 2015년 9월 15일
This works:
IM_1 = randi([1 9], 4, 5); % Create Data
IM_2 = randi([11 19], 4, 5);
IM_data(:,:,1) = IM_1;
IM_data(:,:,2) = IM_2;
  댓글 수: 2
Andrea
Andrea 2015년 9월 15일
I don't want to create data, I already have it. The data also has different dimensions.
Star Strider
Star Strider 2015년 9월 15일
I created the data to test my code.
If your data have different dimensions, use cell arrays:
IM_data{1} = IM_1;
IM_data{2} = IM_2;
If cell arrays are new to you, see the documentation for Cell Arrays, specifically the sections Examples and How To and Concepts for details on how to work with them.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by