1

I am using Matlab GUIDE to control my application. I load two m files using Matlab GUI, calculate Cross-correlation and then display the results of correlation as shown.

%read Template
Temp=Exp0(:,2);
[rowletter, colletter]=size(Temp);
sprintf('the size of template is %d x %d',rowletter, colletter);
%read Target 
recvdata=AA0;
[rowgol, colgol]=size(recvdata);
sprintf('the size of received data is %d x %d',rowgol, colgol);

%find Cross corelation
cc=normxcorr2(Temp, recvdata);
[max_cc,imax]=max(abs(cc(:)));
sprintf('The highest correlation valus is %f.',max_cc)

Now I want the following two things.

  1. Information printed in my command window to be available in my GUI using the Text Box etc.
  2. Is there any alert which can be raised if the correlation is 1.0000.

How can I do these?.

H.K
  • 231
  • 1
  • 2
  • 15
  • Instead of directing output to the command window and trying to mirror it in your gui, just direct output to your gui textbox instead ... – Hoki Aug 19 '16 at 10:06
  • For pointer on how to replicate command window in a gui `textbox`, look at my answer to this question: [display command output to static text](http://stackoverflow.com/questions/31306845/matlab-display-dos-command-output-to-static-text/31316915#31316915) – Hoki Aug 19 '16 at 10:09
  • @Hoki. I have seen that post. You have introduced a function h = gui_MirrorCmdWindow in that post. How can I add this function to my GUI. – H.K Aug 19 '16 at 10:58
  • My first comment was telling you that for the code you presented, **you do not need** to use such undocumented features. You can print your output **directly into the text box of your choice. Do you know the _handle_ name of the target `textbox` of your GUI ? – Hoki Aug 19 '16 at 13:14
  • Yes. I know the handle of my text box. But since I am new to Matlab, I don't know how to link that with my command window output. – H.K Aug 19 '16 at 13:39
  • instead of your `sprintf(...)` instructions, use `msg=sprintf(...); set(txtboxHandle,'String',[get(txtboxHandle,'String') msg '\n']);` and your output will be directed to the textbox. – Hoki Aug 19 '16 at 13:56
  • It is not working. Actually the problem is that the code I have shown is a script I am running from my GUI. But I don't have any control on the script. It is being run in another work space. So in order to use set and get commands, the strings (sprintf) first have to be brought to the GUI work space. – H.K Aug 19 '16 at 14:18
  • That's bad organisation, you'd better convert your script in a function and run it through the GUI. You'd have access to any GUI elements. Also, moving your script into a GUI subfunction is (i) simpler than trying to send data across workspaces and (ii) order of magnitude less complicated than trying to "mirror" the command window. If you read the post linked, you'll see that setting that up involve a lot of trial and error and numerous MATLAB crashes. – Hoki Aug 19 '16 at 14:26

0 Answers0