How to covert a cell array into a matrix filling the inconsistencies dimensions with NaN values and plot it in MATLAB -
this question:
a={[1 2 3]; [1] ; [5 1]};
now want convert variable matrix, this:
[b]=functionx(a)
b= [1 2 3; 1 nan nan; 5 1 nan];
once first question solved, wanna plot matrix, have (i don't know if there more simple way it):
figure;hold on i=1:size(b) plot(b(i,:),'o') end
and graphic:
so, wondering if maybe there way create matlab recognize 1 data, mean, appears in legend "data 1" instead "data 1, info 2 , info 3".
the first part can done this
maxlength = max( cellfun(@(x)(numel(x)),a)); b = cell2mat(cellfun(@(x)cat(2,x,nan*ones(1,maxlength -length(x))),a,'uniformoutput',false));
for sec part utilize this
plot(repmat((1:size(b,1))',size(b,2),1),reshape(b',[],1),'o')
matlab
No comments:
Post a Comment