The sign "~" is not backwards compatible?

6 views (last 30 days)
I am using MATLAB 2010b and I created a GUI in GUIDE. The code generated by Matlab contained a lot of input variables for GUI objects like "hObject" and "eventdata".
The tool which shows you the errors/warnings concerning your code gave messages like: "Input argument 'hObject' might be unused. If this is OK, consider replacing it by ~" I could just click 'Fix' and it did by itself.
I clicked Fix on these error messages, therefore in place of quite a lof of unused input arguments there are tildes (~) in my code now in large amounts, hundreds of them. The problem is that I gave my code to another person, who is using Matlab 2008, and it doesn't recognize the ~ sign. I tried to delete them all, but of course then it returns with "not enough input arguments"
Is there any automatic way to fix this issue? It would be really painful to write back all the input arguments manually and would take hours.
Thank you in advance, László

Accepted Answer

Daniel Shub
Daniel Shub on 9 May 2012
Unfortunately there is no automatic way of doing it. Each ~ can be replaced by a dummy variable name. Something like "dummy" or "temp" might work (assuming you never use dummy/temp as a meaningful variable).
What you want to do is replace
function [x,y,z] = myfun(a,~,c)
with
function [x,y,z] = myfun(a,dummy,c)
and outputs
[x,~,z] = myfun(a,b,c);
with
[x,dummy,z] = myfun(a,b,c);
DO NOT JUST DO A GLOBAL FIND REPLACE for ~, since ~= and ~x means something different and cannot become dummy= and dummyx.
  1 Comment
László Arany
László Arany on 9 May 2012
Thank you, I will try this, and accept your answer in a few days if it's working.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!