The value assigned to variable <variable_name> might be unused
Show older comments
please can any one solve these errors of some lines that have red underline because i am novice in matlab and i don't know the basics
here the code :

all of these lines have the same M-Lint warning "The value assigned to variable variable_name might be unused"
>> variable name which has red underline
thank you
1 Comment
Azzi Abdelmalek
on 25 Dec 2013
Please post your code as a text not as an image.
Answers (3)
Walter Roberson
on 25 Dec 2013
On lines 4 and 7, add the comment
%#OK
at the end of the line.
Change line 12 to
fclose(Fid);
rather than being an assignment.
7 Comments
n
on 26 Dec 2013
Image Analyst
on 26 Dec 2013
Edited: Image Analyst
on 26 Dec 2013
How is this question different than http://www.mathworks.com/matlabcentral/answers/110597-error-unexpected-matlab-operator where Walter and I already started helping you on this question? Why start all over again?
Unused variables are just a warning and do not cause that message box.
Please post father.wav, your m-file, and path1.txt so someone with the appropriate toolboxes (which you still need to list in the Products box under your question) can run your code. For example, what toolbox is melcepst() in?
n
on 27 Dec 2013
Walter Roberson
on 27 Dec 2013
No, you should not add your files to the voicebox toolbox folders.
What you should do, though, is what I indicated in your simultaneous thread on this topic: show us how you invoked the code from vb.net
Image Analyst
on 27 Dec 2013
That's not a Mathworks toolbox, and since probably not many people have it, you may not have a lot of people able to help you. Does your code run if you call it from a different m-file that supplies the same input arguments as you do when you call it from VB?
n
on 27 Dec 2013
Image Analyst
on 27 Dec 2013
Edited: Image Analyst
on 27 Dec 2013
Spaces may be messing you up. MATLAB may be interpreting it as two different strings unless you wrap in single quotes. So instead of this:
Result = MatLab.Execute("cd D:\university\sem9\voicebox toolbox")
try this:
Result = MatLab.Execute("cd 'D:/university/sem9/voicebox toolbox'")
Also try forward slashes, which MATLAB and Windows are just fine with:
Result = MatLab.Execute("C:/Users/TOSHIBA/test2.m")
just in case it's using the backslash to indicate a special character like \t or \n.
Walter Roberson
on 27 Dec 2013
C:\Users\TOSHIBA\test2
is not a valid MATLAB command.
Use addpath() to add C:\Users\TOSHIBA to your MATLAB path, and then use
test2
Alternately, code
Result = MatLab.Execute("run('C:\Users\TOSHIBA\test2.m')")
3 Comments
n
on 27 Dec 2013
n
on 27 Dec 2013
Walter Roberson
on 27 Dec 2013
Result = MatLab.Execute("addpath('C:\Users\TOSHIBA');")
Result = MatLab.Execute("test2");
11 Comments
Walter Roberson
on 28 Dec 2013
You are comparing the result to the string "true", but MATLAB is returning numeric true, which is probably coming through as 1 (and 0 for false)
n
on 28 Dec 2013
n
on 28 Dec 2013
Walter Roberson
on 28 Dec 2013
I am not familiar with Visual Basic. Have you considered altering your MATLAB code to return a string instead of a logical value ?
Image Analyst
on 29 Dec 2013
Try
Dim Result as String
and see what that does. Then you might have to change your if to
if Results = "1" then
n
on 29 Dec 2013
Image Analyst
on 29 Dec 2013
I told you how to change Result to a string like Walter suggested. I don't see any "i" variable so I don't know what you're talking about. Can you put a message box in test2.m as the first line and have it say
uiwait(msgbox('Starting to run test2 now'));
so we can see if test2 is actually being run?
n
on 29 Dec 2013
n
on 29 Dec 2013
n
on 29 Dec 2013
Walter Roberson
on 29 Dec 2013
Neither Image Analyst nor I have experience with that kind of audio work.
Have you now isolated the problem as being with your signal-processing and not with the VB to MATLAB interface? If so then it would be time to open a new third Question for the signal processing part.
Categories
Find more on Matrix Indexing 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!



