Questions about data types and tables
Mostra commenti meno recenti
Data types is not strong side in Matlab, so i'm hoping that someone can help me. See comments in code
%% I'm storing data types of different lenghts as a table. Is a table a good idea?
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=[3 1 2; 8 9 7];
X=table(X1,X2,X3)
%% The code bellow finds the longest entity in the table and writes out any entities shorter,
% X2 in this case.
len=table2array(varfun(@(x) size(x,2),X));
lmax=max(len);
idrest=find(len<lmax);
X(:,idrest)
%% Now i wish to "fill-out" the shorter enteties by adding 'Nan' as seen bellow.
% I now wish to store this new strucutre in the place of the original. This
% is the problem that I can't solve.
for i=idrest(1):idrest(end)
temp=table2array(X(:,i));
temp(:,end+1:lmax)=nan
X.X(:,i)=temp %% Here's the issue
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Tables 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!