How can I store vectors of different sizes into a column array to be then added to Table that was created previously?
15 views (last 30 days)
Show older comments
I wrote two codes that process images. The first script loads the images, allows the user to select the points of interest then stores these in a Table. The next script takes these coordinate values and creates vectors for the region of interst highlighted for each sample. I want to store these vectors in the Table from the previous script but I am running into two issues.
The first is how do I append the table (create new column and add it to table). The second issue is that when I concatnate the vectors (of different sizes) in my loop. I am given an eorror "deimensions of arrays being concatenated are not conisistent". How would I go about resolving this? The vectors will always be of different sizes. My goal is to store these vectors with their appropirate files to be later used for calculatoins and plots ( I plan to plot all the intensity profile for the samples on one plot)/ I am including a sample of the table the first code creates below:
One of the challneges is that I want to store a vector in one cell to be accessed later for when I plot my values for each of my files.
filename cL cR cmid rU rL rmid xVecLen yVecLen OutEdgeL OutEdgeR OutEdgeB OutEdgeT
__________________________________ ___ ___ ____ _____ _____ _____ _______ _______ ________ ________ ________ ________
"2496-2.JPG" 217 583 400 281.5 157.5 219.5 184 63 131 680 99.5 339.5
"2496-1.JPG" 212 492 352 309.5 197.5 253.5 141 57 77 641 121.5 398.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
seg=141;
ROIint=[];
Intensity=[];
c=cell(1,z);
for i= 1:z
%Segment the R.O.I into a series of concentric rectangles
xvector=cL(i):((cmid(i)-cL(i))/seg):cmid(i)
yvector=rL(i):((rmid(i)-rL(i))/seg):rmid(i)
%Loop through rectangluar region of interest defined
for ii= 1:seg
xLroi=xvector(ii)
xRroi=(cmid(i)-xLroi)+cmid(i)
yLroi=yvector(ii)
zz=(rmid(i)-yLroi)
yUroi=rmid(i)+zz
Int=sum(sum(G(yLroi:yUroi,xLroi:xRroi)))
Intensity=[Intensity Int]
end
ROIint=[ROIint; Intensity]
end
3 Comments
Kartikay Sapra
on 25 Aug 2022
As suggested above, you can append variable length vectors into a cell array.
For this particular case, you can create a table with the maxium possible columns and use NaN for missing values.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!