Why does Matlab mex does not have a day type like scanf
3 次查看(过去 30 天)
显示 更早的评论
Here's my problem, I have a c++ code that I'm compiling in mex and so far it's doing great. But it's supposed to take different input from the user to perform different tasks. When it prompts the user to enter the input and canny recognize it. I've read on plenty website that mex doesn't have scanf and getchar. But I fount this example in the Matlab website with the reply and isempty function but that created more errors for me. Is there any other way.
Im using R2007b, and win64,window7.VS 2005.
The part I want to fix goes like this:
scanf("%c%*[^\n]",&ans);
getchar();
If(ans==I){
Do this}
If (ans==b)
{
Do that
}
else
{
Do nothing
}
The code itself runs great in C
Please help
1 个评论
Jan
2013-1-24
What does this sentence mean: "But I fount this example in the Matlab website with the reply and isempty function but that created more errors for me"?
回答(3 个)
Walter Roberson
2013-1-23
This technical note hints you should be able to use scanf() in R2007b: http://www.mathworks.com/support/solutions/en/data/1-1UP8NA/?solution=1-1UP8NA
This FEX contribution might help: http://www.mathworks.com/matlabcentral/fileexchange/30622-non-wait-detection-of-keyboard-input-including-mex-implementation
0 个评论
Jan
2013-1-24
You can use mexCallMATLAB to call Matlab's input() or any other Matlab commands.
0 个评论
Mini Me
2013-1-24
1 个评论
Jan
2013-1-24
Did you read the documentation of this command already? See: doc mexCallMATLAB. Obviously you did not use the command correctly as the error message tells you. If you post the code, we had a chance to give a suggestion for improvements.
Please post comments in the comment section, not as an answer. Thanks.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!