Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Can anyone pls help me with the following code;

1 回表示 (過去 30 日間)
Shenbagalakshmi Veliah
Shenbagalakshmi Veliah 2014 年 11 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
choice=input('enter a no.to be recognized:no.1 for trained words,no.2 for not trained words:');
if choice==1)
[pathname,filename]=uigetfile('*.wav','Select a wave file');
current=strcat(filename,pathname);
input=wavread(current);
disp('y');
else
disp('n');
end
when i give input as 1,then it must enter into 'if'loop or else it should enter into else condition.

回答 (1 件)

Harry
Harry 2014 年 11 月 2 日
Your code is mostly correct, just remove the ")" at the end of your 'if' statement:
if choice==1
  2 件のコメント
Shenbagalakshmi Veliah
Shenbagalakshmi Veliah 2014 年 11 月 2 日
Thank u very much for ur reply Harry.But my problem is that for the first time if i entered '1'it enters the loop and it gets displayed as 'y',for second time if i run the same program it does not ask me the input.so i think the execution itself is stopped for only once.can u pls help me with this problem.
Harry
Harry 2014 年 11 月 3 日
編集済み: Harry 2014 年 11 月 3 日
Ah yes, your problem is that you have named a variable "input"... but you also need to use a function called "input".
Therefore, when you create the variable input=wavread(current), this means you can't call the function choice=input(...) any more.
The easy solution is to rename your variable "input". For example, try this:
choice=input('enter a no.to be recognized:no.1 for trained words,no.2 for not trained words:');
if choice==1
[pathname,filename]=uigetfile('*.wav','Select a wave file');
current=strcat(filename,pathname);
wave=wavread(current);
disp('y');
else
disp('n');
end
In the future, you should always clear all your variables at the start of your code, using:
clear all;
This will prevent many problems like this from happening.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by