include all rows matrix in []
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
piero
il 5 Giu 2023
Commentato: Walter Roberson
il 5 Giu 2023
>> size(z)
ans =
5668 73
BB=[z(:,1),z(:,2),z(:,3)....z(:,73]
i need in [] include all rows z
how can i do it?
2 Commenti
Paul
il 5 Giu 2023
Are you sure the problem is stated correctly? As written, BB will be the same as z.
Here's a small example:
z = rand(2,3)
BB = [z(:,1),z(:,2),z(:,3)]
Risposta accettata
Walter Roberson
il 5 Giu 2023
zc = num2cell(z,1); %1 --> preserve first dimension
[Sis.h] = zc{:}; %or [Sis.h] = deal(zc{:});
0 Commenti
Più risposte (1)
Paul
il 5 Giu 2023
Modificato: Paul
il 5 Giu 2023
One way ....
Create example data
Sis.a = 1;
Sis = repmat(Sis,73,1);
z = rand(5668,73);
The code
[Sis.z] = cell2struct(num2cell(z,1),'z',1).z;
Verify
isequal([Sis.z],z)
1 Commento
Walter Roberson
il 5 Giu 2023
Sis.a = 1;
Sis = repmat(Sis,73,1);
z = rand(5668,73);
[Sis.z] = struct('z', num2cell(z,1)).z;
isequal([Sis.z],z)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!