How can I store vectors of different sizes into a column array to be then added to Table that was created previously?

조회 수: 15 (최근 30일)
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
SnooptheEngineer
SnooptheEngineer 2022년 8월 22일
@Mario Malic each column wouldnt have a different number of rows. The difference would be some columns have one value in it. Others have a vector array stored. Does that make sense? My other main issue to concatnation. I cant seem to store the vectors generated from the loop into an array as they vary in length. What is a solution for that?
Kartikay Sapra
Kartikay Sapra 2022년 8월 25일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by