The value assigned to variable <variable_name> might be unused

18 views (last 30 days)
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

Answers (3)

Walter Roberson
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
n on 27 Dec 2013
the code is run in matlab without error ,only M-lint warning >> test2
ans =
false
and in vb when i call it appear that error message box
and this is how i invoke this matlab code in vb :
Module Module2
Sub main()
Dim MatLab As Object
Dim Result As String
MatLab = CreateObject("Matlab.Application")
MatLab.Execute("enableservice('automationserver',true)")
MatLab.Visible = False
Result = MatLab.Execute("cd D:\university\sem9\voicebox toolbox")
Result = MatLab.Execute("voicebox")
Result = MatLab.Execute("C:\Users\TOSHIBA\test2")
MsgBox(Result)
If Result.Contains("true") Then
My.Computer.Audio.Play("C:\Users\TOSHIBA\clapping.wav", AudioPlayMode.Background)
Else : My.Computer.Audio.Play("C:\Users\TOSHIBA\wrong.wav", AudioPlayMode.Background)
End If
End Sub
End Module
This is the code of record in vb :
Public Class father
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
Button2.Enabled = True
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
mciSendString("record recsound", "", 0, 0)
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = True
mciSendString("save recsound C:\Users\TOSHIBA\nnn.wav", "", 0, 0) ' recordrd file path
mciSendString("close recsound", "", 0, 0)
Dim File_name_a As String = "C:\Users\TOSHIBA\path1.txt"
Dim objwriter As New System.IO.StreamWriter(File_name_a)
objwriter.WriteLine("1")
objwriter.Write("C:\Users\TOSHIBA\nnn.wav")
objwriter.Close()
MessageBox.Show("your voice is recorded")
main()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.Audio.Play("C:\Users\TOSHIBA\nnn.wav", AudioPlayMode.Background)
End Sub
Image Analyst
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.

Sign in to comment.


Walter Roberson
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
n on 27 Dec 2013
i am waiting for you please :( really sorry but because i have to submit the project at the end of this week :(
sorry again
Walter Roberson
Walter Roberson on 27 Dec 2013
Result = MatLab.Execute("addpath('C:\Users\TOSHIBA');")
Result = MatLab.Execute("test2");

Sign in to comment.


n
n on 28 Dec 2013
Edited: n on 28 Dec 2013
it is ok so so thanks Mr and the error doesn't not appear now but appear this voicebox parameters message , i don't know what is it !
second this matlab code is about speech recognition that compares two sound one of them stord sound in database and the second is recorded sound and then returns as result "matching" or a "not matching
when matching , clapping.wav is run
when not matching , wrong.wav is run
as it written in vb code which invoke matlab code
the problem here that the wrong.wav always run in vb although the recorded word is right
even in matlab when i calling test2 the ans is false not true
>> test2
ans =
false
so what is the problem please here is the matlab code do comparing correctly!! because it runs strange sound not the record sound so please can you see what is the problem here
1. what is voicebox parameters msg ?? 2. why the vb run wrong.wav or in matlab " ans = false "??
thank you so much for your cooperation and attention and really sorry :(
  11 Comments
n
n on 29 Dec 2013
please help me :'( my teachers want the project this time and i am very depressed
Walter Roberson
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.

Sign in to comment.

Categories

Find more on Scope Variables and Generate Names in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!