필터 지우기
필터 지우기

How to convert cell to matrix with different size of cell

조회 수: 5 (최근 30일)
Kiran Isapure
Kiran Isapure 2023년 1월 12일
댓글: Kiran Isapure 2023년 1월 12일
I have 10 cell and want to convert it to matrix but I am getting error Dimensions of arrays being concatenated are not consistent.
Movav_data1=cell2mat(Movav_data);
  댓글 수: 1
Jan
Jan 2023년 1월 12일
The error message is clear: You can concatenate only arrays with matching dimensions. What are the sizes of the cell elements? What do you expect as output?

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

답변 (1개)

Cameron
Cameron 2023년 1월 12일
Well the size of the data isn't the same. In the first cell, it is 6,760 rows and the second is 6,761 rows. So it can't combine the two. It would be like doing this
a = [1;2;3];
b = [1;2;3;4];
[a,b] %this gives an error
What are you trying to do with this? You can prepopulate an array with NaNs and fill in your data like this
%loop through to find the largest data set in your cell array
maxRows = 1;
for xx = 1:length(Movav_data)
if length(Movav_data{xx}) > maxRows
maxRows = length(Movav_data{xx});
end
end
NewArray = nan(maxRows,length(Movav_data)); %make NaN array
%loop through your cell array and paste data into NaN array
for yy = 1:length(Movav_data)
NewArray(1:length(Movav_data{yy}),yy) = Movav_data{yy};
end
  댓글 수: 1
Kiran Isapure
Kiran Isapure 2023년 1월 12일
I am trying to index first element, where its greater than ethreshold
activation= find(Movav_data >= ethreshold,1);
But i am not able to index the first element with above line of code

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by