Appending a cell in for loop and accesing

조회 수: 1 (최근 30일)
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022년 5월 30일
답변: VINAYAK LUHA 2023년 9월 7일
Hello sir/Madam,
I was trying appending to a cell, Here my data is 1x11 cells. each cell is m*n size.(my data file came from several '.txt' files)
my output of LVcum is different length, I'm getting error because my data file is different length.
for i=1:numel(data)
clear LDV1_mps
LV1_mps= table2array(data{1,i}(:,4));
LVcum{1,i}= cumsum(double(LV1_mps));
end
I'm getting following error,
Unable to perform assignment because the size of the left side is 58569-by-1 and the size of the right side is 56558-by-1.
I know whats problem is, but I'm not sure how to circumvent this? Can someone help me with this?
Thank you in advance,
  댓글 수: 2
Image Analyst
Image Analyst 2022년 5월 30일
After you read this link
attach data in a .mat file
save('answers.mat', 'data');
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022년 5월 30일
my data file is too big to attach. It was almost 10 MB, coudn't attach and also I can't share that file. Below is sample of my data cell

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

답변 (1개)

VINAYAK LUHA
VINAYAK LUHA 2023년 9월 7일
Hi Chandra,
To the best of my understanding, you are facing issue while appending matrices of different dimensions to a cell iteratively.
I generated some random data as per the description and ran your code in MATLAB R2023a and the code ran just perfectly.
Mentioned below is the testing code-
x = rand(58569,7);
y = rand(56558,7);
z = rand(58458,7);
data{1,1}= array2table(x);
data{1,2}= array2table(y);
data{1,3}= array2table(z);
for i=1:numel(data)
clear LDV1_mps
LV1_mps= table2array(data{1,i}(:,4));
LVcum{1,i}= cumsum(double(LV1_mps));
end
can you give more information related to the error?
Hope this helps!

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by