could anyone help me how to solve the error in the following code
Mostra commenti meno recenti
I am having cell array
B=10x1 cell
which contains
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
10x4 double
I used the following code to convert it
A=cell(size(B));
for i=1:numel(B)
A{i}=splitapply(@(x){x}, 1:numel(B{i}) ,B{i});
disp("YTest{" +i+ "}:"), B{i}
for j=1:numel(A{i})
disp("A{" +i+ "}{"+j+"}:"), A{i}{j}
end
disp ' '
end
But it results in error. Could anyone please help me to overcome it.
Risposte (1)
Walter Roberson
il 16 Lug 2021
0 voti
The last parameter to splitapply must be a vector of positive integers, one for each row of input, with the number indicating which group the row belongs to.
It is not clear that your B values are integers. It is clear that B{i} is not a vector.
Perhaps you accidentally exchanged the second and third parameters.
8 Commenti
jaah navi
il 16 Lug 2021
Walter Roberson
il 16 Lug 2021
That is not possible. The last parameter to splitapply must be a vector. Never a 2d array.
jaah navi
il 16 Lug 2021
Walter Roberson
il 16 Lug 2021
num2cell()
jaah navi
il 16 Lug 2021
jaah navi
il 16 Lug 2021
Unfortunately, you did not explain what output you want.
rng(12345)
B{1} = randi(9, 3, 4);
B{2} = randi(9, 3, 4);
celldisp(B)
What exact output would you want for the above?
jaah navi
il 17 Lug 2021
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!