Info

This question is closed. Reopen it to edit or answer.

Need help in the code GUI!

1 view (last 30 days)
sha
sha on 22 Nov 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi there,
i have some problems with the Gui code. I need to calculate the difference on all the 6 images and display it with the command colormap using my formula.
Heres the code:
-------------------------------
global I1c I2c I3c I4c I5c I6c; // the image
global theta1 theta2 ftheta;
global delta1 delta2 delta3 fdelta;
global averagef N stress;
dia = str2num(get (handles.thickness, 'String'));
fringe = str2num(get (handles.fringe2, 'String'));
theta1=I5c-I3c;
theta2=I4c-I6c;
ftheta=(1/2)*atan(theta1.*theta2);
delta1=I5c-I4c;
delta2=I1c-I2c;
delta3=sin(2.*ftheta)-cos(2.*ftheta);
fdelta=atan(2.*(delta1./(delta2.*delta3)));
N=fdelta./(2*pi);
stress=(N*averagef)/dia;
set(handles.stressDifference, 'String', stress);
axes(handles.axes11)
imagesc(abs(stress)),title('Stress distribution in the tooth'),xlabel('Pixel'),ylabel('Pixel'),colorbar,colormap(jet);
---------------------------------------------
Heres the error:
??? Error using ==> mtimes Inner matrix dimensions must agree.
Error in ==> New>StressButton_Callback at 846 stress=(N*averagef)/dia;
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> New at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)New('StressButton_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I need help in this! THANKS!

Answers (1)

Image Analyst
Image Analyst on 22 Nov 2012
You're doing a matrix multiplication (not an element-by-element multiplication) of N and averagef. They are different sizes. Set a breakpoint there and find out what sizes they are. Learn how to use the debugger and these kinds of problems can be solved in seconds without the long delay involved in asking us.

Community Treasure Hunt

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

Start Hunting!