These are my inputs how can i use str2num in title so that i can display the values of inputs?
1 次查看(过去 30 天)
显示 更早的评论
A=input('amplitude= ')
N=input('period= ')
I get the following errors ??? Error using ==> title at 29 Incorrect number of input arguments
Error in ==> title at 23 h = title(gca,varargin{:});
how can i solve the issue?
1 个评论
回答(2 个)
Walter Roberson
2015-6-18
A=input('amplitude= ')
N=input('period= ')
title(sprintf('Amplitude = %f mm, Period = %f s', A, N))
0 个评论
Stephen23
2015-6-18
编辑:Stephen23
2015-6-18
A = str2double(input('amplitude= ','s'));
N = str2double(input('period= ','s'));
title(sprintf('Amplitude = %g mm, Period = %g s', A, N))
This avoids the possibility of arbitrary code being input and executed, which is what input without the 's' option will do.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!