- Is that [123; 456; 789], which is a 3-by-1 column vector of 3-digit numbers?
- Or do you mean {'123'; '456'; '789'} which is a 3-by-1 cell array of strings?
- Or do you want a 3-by-1 array of cells where each cell contains a 1-by-3 row vector of numbers, like {[1,2,3]; [4,5,6]; [7,8,9]}?
Matrix row cell concatenation
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have a matrix and I would like to combine its row cells as an array of the matrix.
Ex:a
1 2 3
4 5 6
7 8 9
result:b
123
456
789
I tried a solution to from this link:
a = [ 8 1 6 ; 1 2 3 ; 4 5 6 ]
[l c ] = size (a) ;
b = cell (l,1);
for i =1 : l
b {i,: } = [ a(i,1) a(i,2) a(i,3) ] ;
end
but I get the out put as
ans =
[1x3 double]
[1x3 double]
[1x3 double]
any help would be appreciated. Thnx
4 commentaires
Réponses (1)
madhan ravi
le 20 Juil 2019
Modifié(e) : madhan ravi
le 20 Juil 2019
b = reshape(arrayfun(@(x)polyval(a(x,:),10),...
1:size(a,1),'un',0),[],1);
Wanted = cell2mat(b)
4 commentaires
madhan ravi
le 20 Juil 2019
Modifié(e) : madhan ravi
le 22 Juil 2019
What more do you need ? Doesn't the below give what you want??
>> a = [1 2 3
4 5 6
7 8 9 ];
>> bb=num2cell(string(a),1);
>> b=str2double(strcat(bb{:}))
b =
123
456
789
>> size(b)
ans =
3 1 % 3 by 1 vector
>>
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!