need help about opening dicom file in matlab - matlab

i got black image when opening dicom file in matlab
my code for opening dicom files
[real_image,real_path] = uigetfile( ...
{'*.*;','File Dicom (*.dcm)';},...
'Open Image');
if ~isequal(real_image,0)
handles.image = dicomread(fullfile(real_path,real_image));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.image);
set(handles.text5,'String',real_image);
set(handles.text6,'String',real_path);
[row,column]=size(handles.image);
set(handles.text7,'String',row);
set(handles.text8,'String',column);
else
return;
end

I've tested your code by creating a GUI (R2012b) and inserting the code in pushbutton callback and it works fine.
So I can see two possibilities:
- the dcom image you are loading in somehow corrupted
- the dcom image is good and it is a probelm of contrast
I'll go for the second possibility.
I've used, as examples, the dcom images "CARDIX" downloaded from DICOM sample image sets.
As one of these images is loaded, it appears to be black and the axes's clim is [0 65535].
If you set the clim range to, respectively, the minimum and maximum values of the dcom image data value, you can start "seeing something".
To further enhance the visibility of the image you can use the imcontrast tool.
In the following you can find the .m file of the GUI: the imcontrast tool can be run through a pushbutton.
function varargout = adjust_contrast(varargin)
% ADJUST_CONTRAST MATLAB code for adjust_contrast.fig
% ADJUST_CONTRAST, by itself, creates a new ADJUST_CONTRAST or raises the existing
% singleton*.
%
% H = ADJUST_CONTRAST returns the handle to a new ADJUST_CONTRAST or the handle to
% the existing singleton*.
%
% ADJUST_CONTRAST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ADJUST_CONTRAST.M with the given input arguments.
%
% ADJUST_CONTRAST('Property','Value',...) creates a new ADJUST_CONTRAST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before adjust_contrast_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to adjust_contrast_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help adjust_contrast
% Last Modified by GUIDE v2.5 26-Dec-2015 10:44:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #adjust_contrast_OpeningFcn, ...
'gui_OutputFcn', #adjust_contrast_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before adjust_contrast is made visible.
function adjust_contrast_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 adjust_contrast (see VARARGIN)
% Choose default command line output for adjust_contrast
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes adjust_contrast wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = adjust_contrast_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[real_image,real_path] = uigetfile( ...
{'*.dcm;','File Dicom (*.dcm)';},...
'Open Image');
if ~isequal(real_image,0)
handles.image = dicomread(fullfile(real_path,real_image));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.image);
set(handles.text5,'String',real_image);
set(handles.text6,'String',real_path);
[row,column]=size(handles.image);
set(handles.text7,'String',row);
set(handles.text8,'String',column);
else
return;
end
% Set the "Clim" scale to the [min max] image values
set(gca,'clim',[min(min(handles.image)) max(max(handles.image))])
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
imcontrast
In the following picture you can see:
- the "black" image as it appears as loaded
- the first enhacement following the updating of the clim range
- the enhancements obtained "working" with the imcontrast tool
Notice: you can download a DCOMViewer from MATLAB Central.
Hope this helps.

Related

Matlab Attempt to reference field of non-structure array

I have 3 figures
1- principle contain 2 buttons
2- figure to load one image and diplay it on an axe
3- figure to load two images and diplay it on axes
when i run the figure 3 or 2 all alone everything is fine and the images got displayed.
THE PROBLEM when i run the prgrm from principle.fig and open the 2nd figure or the 3rd an error popup
Attempt to reference field of non-structure array.
Error in untitled3>pere_Callback (line 91)
axes(handles.axes1);
my code
function varargout = untitled3(varargin)
% UNTITLED3 MATLAB code for untitled3.fig
% UNTITLED3, by itself, creates a new UNTITLED3 or raises the existing
% singleton*.
%
% H = UNTITLED3 returns the handle to a new UNTITLED3 or the handle to
% the existing singleton*.
%
% UNTITLED3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED3.M with the given input arguments.
%
% UNTITLED3('Property','Value',...) creates a new UNTITLED3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled3_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled3
% Last Modified by GUIDE v2.5 01-May-2017 17:19:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #untitled3_OpeningFcn, ...
'gui_OutputFcn', #untitled3_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled3 is made visible.
function untitled3_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 untitled3 (see VARARGIN)
% Choose default command line output for untitled3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled3_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pere.
function pere_Callback(hObject, eventdata, handles)
% hObject handle to pere (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im im2
[path,user_conce] = imgetfile();
if user_conce
sprintf('error');
return
end
im=imread(path);
im2 = im; %backup
im = im2double(im);
im = rgb2gray(im);
axes(handles.axes1);
imshow(im);
% --- Executes on button press in fils.
function fils_Callback(hObject, eventdata, handles)
% hObject handle to fils (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im3 im4
[path,user_conce] = imgetfile();
if user_conce
sprintf('error');
return
end
im3=imread(path);
im4 = im3; %backup
im3 = im2double(im3);
im3 = rgb2gray(im3);
axes(handles.axes3);
imshow(im3);
% --- Executes on button press in tester.
function tester_Callback(hObject, eventdata, handles)
% hObject handle to tester (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

Create a gui in matlab

I want to create a gui in matlab with a push button and a panel.
Requirements: Upon clicking the button the dialogue must open to choose a file and after selecting image from this dialogue the image must be shown to that panel of gui.
How do I do this?
How to show the image on the gui panel?
My current status so far:
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = ...
uigetfile({'*.jpg';'*.png';'*.jpeg';'*.bmp';'*.*'},'File Selector');
set(handles.axes2, 'Visible','on');
imshow(IMG,'Parent',TheAxisHandleToDrawOn)
if isequal(filename,0)
disp('Image upload Canceled')
end
I tried this but it's not working, how to do this?
With respect to your callback you have first to read the selected image by using imread; you can use fullfile to build the complete filename.
Then you use the matrix returned by imread as input for the imshow function.
Edit following the comments
In order to show the image within a uipanel you have to add an axes in the panel and use it as parent in the call to imshow.
If the image you want to display is not in the current folder or in a folder on the MATLAB path, you have to specify the full path name (ref. imread).
In the following you can find the .m file of the GUI I've build for test.
The GUI contains:
an axes (tag: axes2)
a uipanel (tag: uipanel1)
an axes (tag: axes_up) embedded in the uipanel
two radiobuttons (tag: radiobutton1 and radiobutton2) to select the axes on which to show the image
two statictext fields (tag: text2 and text3) to show the filename of the selected images
a pushbutton (tag: pushbutton1) to select the image to be displayed
a pushbutton (tag: pushbutton3) to run the imcontrast tool in case of selection of a .dcm image
The code has been tested on R2012b and 2015b.
function varargout = disp_fig(varargin)
% DISP_FIG MATLAB code for disp_fig.fig
% DISP_FIG, by itself, creates a new DISP_FIG or raises the existing
% singleton*.
%
% H = DISP_FIG returns the handle to a new DISP_FIG or the handle to
% the existing singleton*.
%
% DISP_FIG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DISP_FIG.M with the given input arguments.
%
% DISP_FIG('Property','Value',...) creates a new DISP_FIG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before disp_fig_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to disp_fig_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help disp_fig
% Last Modified by GUIDE v2.5 25-Apr-2016 14:18:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #disp_fig_OpeningFcn, ...
'gui_OutputFcn', #disp_fig_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before disp_fig is made visible.
function disp_fig_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 disp_fig (see VARARGIN)
% Choose default command line output for disp_fig
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes disp_fig wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = disp_fig_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Select the image to be displayed
[filename, pathname] = ...
uigetfile({'*.jpg';'*.png';'*.jpeg';'*.bmp';'*.*'},'File Selector');
% Build the full filename
img_file=fullfile(pathname,filename)
% Split the filename to get its extension
[the_path,the_name,the_ext]=fileparts(img_file);
% Set the current StaticText uicontrol based on the selected RadioButton
curr_txt=handles.text2;
if(get(handles.radiobutton2,'value'))
curr_txt=handles.text3;
end
% Check for image valid selection
if isequal(filename,0)
disp('Image upload Canceled')
set(curr_txt,'string','Image upload Canceled')
else
% If an image has been selected
set(curr_txt,'string',img_file)
% If the image is a ".dcm"
if(strcmp(the_ext,'.dcm'))
% Read it with dicomread and enable the pushbutton to run the
% IMCONTRAST tool
IMG=dicomread(img_file);
set(handles.pushbutton3,'visible','on')
else
% If the image is a ".jpg", ".bmp", ...
% Read it with imread and disable the pushbutton to run the
% IMCONTRAST tool
IMG=imread(img_file);
set(handles.pushbutton3,'visible','off')
end
% Identify the axes on which to display the image according to the
% selected radiobutton
if(get(handles.radiobutton1,'value'))
the_parent=handles.axes2;
set(handles.axes2, 'Visible','on');
else
the_parent=handles.axes_up;
end
% Showthe image
imshow(IMG,'Parent',the_parent)
end
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
% If the first radiobutton has been selected, disable the second onre
r1=get(handles.radiobutton1,'value');
if(r1)
set(handles.radiobutton2,'value',0);
end
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
% If the second radiobutton has been selected, disable the first one
r2=get(handles.radiobutton2,'value');
if(r2)
set(handles.radiobutton1,'value',0);
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Run the IMCONTRAST tool to the proper axes according to the selected
% radiobutton
r1=get(handles.radiobutton1,'value');
if(r1)
imcontrast(handles.axes2)
else
imcontrast(handles.axes_up)
end
Structure of the GUI
The GUI ... working
To test the .dcm image display I've used, as examples, the images from DICOM sample image sets.
Hope this helps.
Qapla'
this is the final solution for the problem
function browse_Callback(hObject, eventdata, handles)
% hObject handle to browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname]=uigetfile( {'.jpg';'.gif';'.png';'.bmp'},'Select file');
MyImage = strcat(pathname, filename);
%This code checks if the user pressed cancel on the dialog.
if isequal(filename,0) || isequal(pathname,0)
uiwait(msgbox ('User pressed cancel','failed','modal') )
hold on;
else
uiwait(msgbox('User selected image sucessfully','sucess','modal'));
hold off;
imshow(MyImage,'Parent',handles.axes1);
end
global Imagevariable;
Imagevariable=MyImage;
handles.output = hObject;
guidata(hObject, handles);

how can i loop Bold one using 'for' function in the matlab?

function varargout = voltagealgorithm20150226gui3rd(varargin)
% VOLTAGEALGORITHM20150226GUI3RD MATLAB code for voltagealgorithm20150226gui3rd.fig
% VOLTAGEALGORITHM20150226GUI3RD, by itself, creates a new VOLTAGEALGORITHM20150226GUI3RD or raises the existing
% singleton*.
%
% H = VOLTAGEALGORITHM20150226GUI3RD returns the handle to a new VOLTAGEALGORITHM20150226GUI3RD or the handle to
% the existing singleton*.
%
% VOLTAGEALGORITHM20150226GUI3RD('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VOLTAGEALGORITHM20150226GUI3RD.M with the given input arguments.
%
% VOLTAGEALGORITHM20150226GUI3RD('Property','Value',...) creates a new VOLTAGEALGORITHM20150226GUI3RD or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before voltagealgorithm20150226gui3rd_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to voltagealgorithm20150226gui3rd_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help voltagealgorithm20150226gui3rd
% Last Modified by GUIDE v2.5 26-Feb-2015 14:51:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #voltagealgorithm20150226gui3rd_OpeningFcn, ...
'gui_OutputFcn', #voltagealgorithm20150226gui3rd_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before voltagealgorithm20150226gui3rd is made visible.
function voltagealgorithm20150226gui3rd_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 voltagealgorithm20150226gui3rd (see VARARGIN)
% Choose default command line output for voltagealgorithm20150226gui3rd
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes voltagealgorithm20150226gui3rd wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = voltagealgorithm20150226gui3rd_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
cla;
for i=1:3
switch popup_sel_index
case i
x = [1:1:2]
**xlRange = ('A1:B1');**
y = xlsread('naver.xlsx','data',xlRange);
plot(x,y)
end
end
i wanna make A1:B2 to A2:B2 and A3:B3 .......
i tried ('A(i):B(i)') but it failed and matlab says Data range is invalid
plz help me solve this problem
how can i make A1:B2 to A2:B2 and A3:B3 by using 'for function'?
To fix this, you would have to create a matching string:
['A' num2str(i) ':B' num2str(i)]
For performance reasons, I recommend to read all three lines outside the loop in one call of xlsread.
for k=1:1:4
[~,~,raw] = xlsread('data.xlsx','data1');
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case k
xlRange = sprintf('E%d:CW%d',k,k);
x1 = [0.25:0.25:24]
xlRange
y1 = xlsread('data.xlsx','data1',xlRange);
plot(x1,y1)
end
i found the answer

Making simple table in MATLAB GUI, like Excel

I just want to make a simple table like Excel in MATLAB GUI. Please see attached fig:
Column 'unit' and 'value' are editable. Column 'sum' should be unit*value.
Questions:
How can I add header parameters?
How can I change property of column 'sum'= unit*value?
How can I change property of column 'Result'=sum ' sum' column / EDOC?
I just made demo input.
% Code% sim.m
function varargout = Sim(varargin)
% SIM MATLAB code for Sim.fig
% SIM, by itself, creates a new SIM or raises the existing
% singleton*.
%
% H = SIM returns the handle to a new SIM or the handle to
% the existing singleton*.
%
% SIM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIM.M with the given input arguments.
%
% SIM('Property','Value',...) creates a new SIM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Sim_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Sim_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Sim
% Last Modified by GUIDE v2.5 25-Dec-2014 15:33:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #Sim_OpeningFcn, ...
'gui_OutputFcn', #Sim_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Sim is made visible.
function Sim_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 Sim (see VARARGIN)
% Choose default command line output for Sim
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Sim wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Sim_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object deletion, before destroying properties.
function Costfunction_DeleteFcn(hObject, eventdata, handles)
% hObject handle to Costfunction (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function Costfunction_CreateFcn(hObject, eventdata, handles)
% hObject handle to Costfunction (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
A matlab component called uitable will be your GUI object.
Editing the value interactively could be done in different ways, this has a complete example.

Matlab GUI, use an input for a static text box and convert it with a basic push button

I am struggling with how the Matlab gui interface works.
I am not looking for an answer, only some more guidance of how to do this.
I am trying to convert a temperature in an edit box from F to C...so I think I need the equation to be in the push button.
I guess I am stuck on how to pass the number from the edit box to the push button to convert it, then how to pass it back, then display it.
Does this make any sense?
function varargout = ICA09A_TEMPFtoC(varargin)
% ICA09A_TEMPFTOC MATLAB code for ICA09A_TEMPFtoC.fig
% ICA09A_TEMPFTOC, by itself, creates a new ICA09A_TEMPFTOC or raises the existing
% singleton*.
%
% H = ICA09A_TEMPFTOC returns the handle to a new ICA09A_TEMPFTOC or the handle to
% the existing singleton*.
%
% ICA09A_TEMPFTOC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ICA09A_TEMPFTOC.M with the given input arguments.
%
% ICA09A_TEMPFTOC('Property','Value',...) creates a new ICA09A_TEMPFTOC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ICA09A_TEMPFtoC_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ICA09A_TEMPFtoC_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help ICA09A_TEMPFtoC
% Last Modified by GUIDE v2.5 20-Mar-2013 13:14:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', #ICA09A_TEMPFtoC_OpeningFcn, ...
'gui_OutputFcn', #ICA09A_TEMPFtoC_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before ICA09A_TEMPFtoC is made visible.
function ICA09A_TEMPFtoC_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 ICA09A_TEMPFtoC (see VARARGIN)
% Choose default command line output for ICA09A_TEMPFtoC
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ICA09A_TEMPFtoC wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ICA09A_TEMPFtoC_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in convert_pb.
function convert_pb_Callback(hObject, eventdata, handles)
% hObject handle to convert_pb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
InputString = get(handles.convert_pb,'Convert');
InputNumber = str2num(InputString);
Result = (5 / 9) * (InputNumber - 32);
set(handles.result, 'Convert', Result);
function degF_et_Callback(hObject, eventdata, handles)
% hObject handle to degF_et (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of degF_et as text
% str2double(get(hObject,'String')) returns contents of degF_et as a double
UserInput = str2double(get(hObject,'String'))
% --- Executes during object creation, after setting all properties.
function degF_et_CreateFcn(hObject, eventdata, handles)
% hObject handle to degF_et (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Is there anything I should do to make this more readable for anyone editing?
To get the temperature entered in the text edit box use:
tempF = get(handles.degF_et,'String');
This can be called from the push button function.
To change the string that is displayed there use:
set(handles.degF_et,'String','some string');