# Attempt to grow array along ambiguous dimension. How to fix?

6 views (last 30 days)
carpeta=uigetdir;
cd(carpeta);
I=dir('*.tif');
nI=size(I,1);
nombreTIFF=cell(nI,1);
PI=zeros(nI,1);
for i=1:nI
Celula_red = Celula(:,:,1);
Celula_green = Celula(:,:,2);
Celula_blue = Celula(:,:,3);
aver = fspecial('average', 5);
Celula_bluef = imfilter(Celula_blue, aver, 'same');
etiquetas=bwlabeln(Celula_full);
eti_grandes=etiquetas.*Celula_erode;
eti_finales=unique(eti_grandes);
eti_finales(eti_finales==0)=[];
mascara=zeros(size(Celula_blue));
for i=1:size(eti_finales,1)
mascara(etiquetas==eti_finales(i))=1;
end
[eti_mascara,n]=bwlabeln(mascara);
aver = fspecial('average', 5);
Celula_greenf = imfilter(Celula_green, aver, 'same');
BW=edge(ventana_green,'log');
Celula_log_fill=imfill(BW,'holes');
Foci=double(Celula_greenf).*double(Celula_log_fill);
area_celula=sum(mascara_blue(:)>0);
numero_foci= nf;
foci_por_area=numero_foci/area_celula;
for e=1:n
area_celula=sum(mascara_blue(:)>0);
numero_foci=max(max(unique(contar_foci)));
foci_por_area=numero_foci/area_celula;
end
end
Attempt to grow array along ambiguous dimension.
ALVARO TORRECILLAS CORTES on 27 Jun 2022
Now it is working in the right way, but the result that i have to obtain aren't the correct ones.
How can i do to separate the result from each image, because it only says:
1.0996e-04
7.2114e-04
4.1018e-04
4.0050e-04

Steven Lord on 27 Jun 2022
This error occurs when you try to assign to an element beyond the last of a matrix but it's not clear what size the resulting larger array should be. If you try to assign to an element past the last of a vector, MATLAB assumes you want to keep the array as a vector and have it keep the same shape.
x = 1:4 % x is a row vector
x = 1×4
1 2 3 4
x(5) = 5 % x stays a row vector, just one element longer
x = 1×5
1 2 3 4 5
y = x.' % y is a column vector
y = 5×1
1 2 3 4 5
y(6) = 6 % y stays a column vector, just one element longer
y = 6×1
1 2 3 4 5 6
If you use linear indexing with a matrix, MATLAB doesn't know if you want to add another row or another column. If the code below did not error, what would you expect the size of z to be after the assignment to element 5? Should it be 2-by-3, 3-by-2, or 2-by-2-by-2?
z = [1 2; 3 4]
z = 2×2
1 2 3 4
z(5) = 5
Attempt to grow array along ambiguous dimension.
You haven't told us on which line the error occurs (if you run your code as a script file or as a function file rather than evaluating selection or copying the code into the Command Window the error should include that information) but likely one of your assignment statements isn't doing what you think it's doing. Find out which line is throwing the error and look at the sizes and values of the variables used on that line.

ALVARO TORRECILLAS CORTES on 27 Jun 2022
That it is the error
In nume (line 50)
numero_foci=max(max(unique(contar_foci)));
ALVARO TORRECILLAS CORTES on 27 Jun 2022
Don't worry, I think I have solved the problem that I have with the programme.
Thank you so much!