Hi,
I'm the beginner in using GUI MATLAB and need some help. I did some coding in GUI main_OpeningFcn to solve the similar coding in m-file. That coding is the main coding for my GUI, and the result depends on the user selection.
Then, I try to use pop-menu to display the result on the axes according the selection chosen in the pop-up menu. Each selection item from pop-up menu has its own .mat file and solve the algorithm that I code according to which item I selected.The result will display on the axes in GUI.
This is my coding in m-file:
function LBP_FBP_YAW_comsol_SM clc, clear all, close all; %each projection e1 till e16 from COMSOL in cell form :EachProj
load('EveryProjection.mat'); % ---------- Dot product to get each pairing projection -----------
i=1; for i=1:16 %eliminate NAN values for each projection,e1 to e16
e=EachProj{1,i}; d=isnan(e); e(d)=0; EachProj{1,i}=e; end for i=1:16; m1=EachProj{1,i}; for j=1:16 m2=EachProj{1,j}; c=m1.*m2; % Do the element multiplication to get Ei,j
E{i,j}=c; end end %-------- Total Map/ Weight Balanced Map----------------------------------
WBMap = zeros(128); for n=1:16; for m=1:16; WBMap = WBMap + E{n,m}; %%%Add coding for WBMap..x perlu load file WBMap yg buat cara panjang
end end %%%for filter matrix;
b = max(WBMap(:)); % choose max magintude pixel in total map
f = b./WBMap; % then, divide with total map to get the filter matrix
%------------- Normalize each pair projection,NormEi,j--------------------
for i=1:16; for j=1:16 N{i,j} = E{i,j}./WBMap; end end %%-------------------- LINEAR BACK PROJECTION(LBP)-----------------------
disp('Displaying Tomogram...'); load('SensorLossE1110mm.mat'); Attenuate_xy = SLe1110mm ; Resolution = 128; % --- IMAGE PIXEL SIZE
DispMap = zeros(Resolution); %view = 1;
for Tx = 1:16; for Rx = 1:16; DispMap = DispMap + (Attenuate_xy(Rx,Tx) * N{Rx, Tx}); %%%coding for getting LBP
end end %%------- coding to get the FILTERED BACK PROJECTION (FBP) algorithm ------
DispMapFBP = zeros(Resolution); %view = 1;
DispMapFBP = f .* DispMap; %%%FBP coding; filter matrik x LBP
% ----- DISPLAY TOMOGRAM RESULT--------------------------------------------
imagesc(DispMapFBP),imagesc(DispMap), shading interp; N = Resolution; r = N/2; % figure('Name','TEST','NumberTitle','off')
Clim = max(DispMapFBP(:)); Clim = max(DispMap(:)); %%%%%%%Plot figure LHS for FBP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('Name','Filtered Back Projection','NumberTitle','off') subplot(1,2,1) pcolor(DispMapFBP); axis square, axis on; %M1 = mask_im(M1,N,r);
CircleBoarder.displayTomo(DispMapFBP, Resolution, Clim); %---- to standardized
set(gca,'YDir','normal'); % To invert the imagesc plot coz imagesc plot top to bottom
caxis([0, 0.14]) colorbar; %%%%%%%Plot figure RHS for LBP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('Name','Linear Back Projection','NumberTitle','off') subplot(1,2,2) pcolor(DispMap); axis square, axis on; %M1 = mask_im(M1,N,r); CircleBoarder.displayTomo(DispMap, Resolution, Clim); %---- to standardized set(gca,'YDir','normal'); % To invert the imagesc plot coz imagesc plot top to bottom caxis([0, 0.014]) colorbar; function a=mask_im(a,M,r) for i=1:M for j=1:M if sqrt((i-M/2)^2+(j-M/2)^2)>=r a(i,j)=0; end end end
Then, I try to use the coding in GUI function OpeningFCn:
% --- Executes just before Noninvasive_ERT_new3 is made visible.
function Noninvasive_ERT_new3_OpeningFcn(hObject, eventdata, handles, varargin) global DispMap; global Attenuate_xy; global DispMapFBP; % This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Noninvasive_ERT_new3 (see VARARGIN)
% Choose default command line output for Noninvasive_ERT_new3
handles.output = hObject; %each projection e1 till e16 from COMSOL in cell form :EachProj singleProj=load('EveryProjection.mat'); SP=singleProj.EachProj; %SP=single projection
% ---------- Dot product to get each pairing projection ----------- i=1; for i=1:16 %eliminate NAN values for each projection,e1 to e16 e=SP{1,i}; d=isnan(e); e(d)=0; SP{1,i}=e; end for i=1:16; m1=SP{1,i}; for j=1:16 m2=SP{1,j}; c=m1.*m2; % Do the element multiplication to get Ei,j E{i,j}=c; end end %-------- Total Map/ Weight Balanced Map---------------------------------- WBMap = zeros(128); for n=1:16; for m=1:16; WBMap = WBMap + E{n,m}; %%%Add coding for WBMap..x perlu load file WBMap yg buat cara panjang end end %%%for filter matrix; b = max(WBMap(:)); % choose max magintude pixel in total map f = b./WBMap; % then, divide with total map to get the filter matrix %------------- Normalize each pair projection,NormEi,j-------------------- for i=1:16; for j=1:16 N{i,j} = E{i,j}./WBMap; end end %%-------------------- LINEAR BACK PROJECTION(LBP)----------------------- disp('Displaying Tomogram...'); Attenuate_xy = get(handles.position_select, 'string') ; Resolution = 128; % --- IMAGE PIXEL SIZE handles.Attenuate_xy=Attenuate_xy; DispMap = zeros(Resolution); %view = 1; for Tx = 1:16; for Rx = 1:16; DispMap = DispMap + (Attenuate_xy(Rx,Tx) * N{Rx, Tx}); %%%coding for getting LBP handles.DispMap=DispMap; end end %%------- coding to get the FILTERED BACK PROJECTION (FBP) algorithm ------ DispMapFBP = zeros(Resolution); %view = 1; DispMapFBP = f .* DispMap; %%%FBP coding; filter matrik x LBP handles.DispMapFBP=DispMapFBP; % ----- DISPLAY TOMOGRAM RESULT-------------------------------------------- shading interp; N = Resolution; r = N/2; Clim = max(DispMapFBP(:)); Clim = max(DispMap(:)); image1= subplot(2,1,1, 'Parent',handles.image_axes); pcolor(image1,handles.DispMapFBP); axis square, axis on; %M1 = mask_im(M1,N,r); CircleBoarder.displayTomo(DispMapFBP, Resolution, Clim); %---- yg ni bila letak comment wrna sam cm yg sblh kanan,So solution re-range color bar sblh kanan
set(gca,'YDir','normal'); % To invert the imagesc plot coz imagesc plot top to bottom caxis([0, 1]) colorbar; image2= subplot(2,1,2, 'Parent',handles.image_axes); pcolor(image2,handles.DispMap); axis square, axis on; %M1 = mask_im(M1,N,r); CircleBoarder.displayTomo(DispMap, Resolution, Clim); %---- yg ni bila letak comment wrna sam cm yg sblh kanan,So solution re-range color bar sblh kanan set(gca,'YDir','normal'); % To invert the imagesc plot coz imagesc plot top to bottom caxis([0, 1]) colorbar; function a=mask_im(a,M,r) for i=1:M for j=1:M if sqrt((i-M/2)^2+(j-M/2)^2)>=r a(i,j)=0; end end end
Next,from pop-menu callback function:
% --- Executes on selection change in position_select.
function position_select_Callback(hObject, eventdata, handles) % hObject handle to position_select (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns position_select contents as cell array
% contents{get(hObject,'Value')} returns selected item from position_select
%gets the selected option
switch get(handles.position_select,'Value') case 'center' % select center phantom
datastruct=load('SensorLossCenter20mmComsol221015.mat'); SL1 = datastruct.SL20mmcentercomsol; handles.SL1=SL1; handles.Attenuate_xy=handles.SL1; case 'single' % select single phantom
datastruct=load('SensorLossE1110mm.mat'); SL2 = datastruct.SLe1110mm; handles.SL2=SL2; handles.Attenuate_xy=handles.SL2; case 'double' % select double phantoms
case 'triple' % select triple phantoms
case 'multiple' % select multiple phantoms
otherwise end % Update handles structure
guidata(hObject, handles);
However, when I run the GUI itself didnt appears and the error shown in command window:
>> Noninvasive_ERT_new3Displaying Tomogram...Undefined function 'mtimes' for input arguments of type 'cell'.Error in Noninvasive_ERT_new3>Noninvasive_ERT_new3_OpeningFcn (line 121) DispMap = DispMap + (Attenuate_xy(Rx,Tx) * N{Rx, Tx}); %%%coding for getting LBPError in gui_mainfcn (line 221) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});Error in Noninvasive_ERT_new3 (line 42) gui_mainfcn(gui_State, varargin{:});
What is it mean by undefined 'mtimes'? Or I cant use that '*' symbol? Is it correct the handles that I'm used in the coding?
Best Answer