## How to store vectors into a matrix that have different sizes?

### Robert Flores (view profile)

on 3 Apr 2019
Latest activity Answered by Jos (10584)

### Jos (10584) (view profile)

on 3 Apr 2019
Hello,
I am trying to make a for loop such that I am able to extract median values I did a DIC analysis on. I think the issue is that the sizes of my output verctors are different, therefore it doesn't want to store it in a differently sized matrix, if that makes sense. Below is my code, but I don't know how you will be able to check my code, because you don't have the data from the N_corr software I used for the DIC analysis. Unfortunately,I cannot attach the workspace it is greater than 5MB and I cant zip it because I'll have to close my code and lose my data; so I don't want to do that. I hope my question is weel posed enough that you are able to help me, thanks.
-Robert
Data = handles_ncorr.data_dic;
% The displacements in the Y-direction
V = zeros(297,448);
Vyy = zeros(20863,1);
for i = 1:8
V(:,:,i) = handles_ncorr.data_dic.displacements(i).plot_v_ref_formatted;
avg(i) = mean(mean(V(:,:,i)));
med(i) = median(median(V(:,:,i)));
end
path = "C:\Users\rober\Documents\MATLAB"; filename = 'Medium_Values.csv';
fileid = fopen(path+'\'+filename,'w');
csvwrite(path+'\'+filename,med)
winopen(filename)

### possibility (view profile)

on 3 Apr 2019

Hi Robert,
As far as I understand, your remedy is cell arrays. You can collect arbitrary size of vectors into one cell array. In fact, not only different size of vectors, you can even combine different data types. Please check: