Unexpected error in a pushbutton function.
    2 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have the following code in a pushbutton function:
pixel = uigetfile('*.jpg');
K     = imread(pixel);
[row col] = size(K);
Kmm  = 1/col
setappdata(0, 'Kmm', Kmm);
guidata(hObject, handles)
After that, I wanna go to another pushbutton which has the following code in some part of it:
Kmm     = getappdata(0, 'Kmm');
reg_prop = regionprops(wat, 'all');
for i=1:smax; 
    Area_surface(i) = reg_prop(i).Area;
end;
max_area         = max(Area_surface);
min_area         = min(Area_surface);
sum_Area_surface = sum(Area_surface);
diamerisi_area = 6;
omega          = zeros(1000,1);
for i=1:smax 
  Area_surface(i) = Area_surface(i)*Kmm^2;
  bin(i)          = int16(Area_surface(i)*10 + 1);
  omega(bin,1)    = omega(bin,1)+1;
end
When it runs I get the following message:
???  In an assignment  A(I) = B, the number of elements in B and
 I must be the same.
Error in ==> lets_see>pushbutton7_Callback at 331
  Area_surface(i) = Area_surface(i)*Kmm^2;
Error in ==> gui_mainfcn at 96
        feval(varargin{:});
Error in ==> lets_see at 42
    gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)lets_see('pushbutton7_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I can't understand why the number of elements is not the same.
0 Commenti
Risposta accettata
  Walter Roberson
      
      
 il 23 Gen 2013
        At the command window, type
dbstop if error
and then run your code. It will stop when the error is encountered.
My guess is that you will find that your retrieved Kmm is empty -- though the reason for that is not obvious to me.
Caution: if your jpg is RGB then size() of it will have 3 dimensions, but when you size() it you only give two outputs. An oddity of size() is that in such a case the last output you allow will contain the product of all the remaining dimensions (and thus the number of columns times 3 in the case where the array has 3 color planes.)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Other Formats in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

