我有一个程序,我希望能够通过输入更改线型,但在从-到-再从-到-的更改中遇到了一些问题。它给出了‘选择样式已经被使用’的消息,我怎样才能让程序看到它们之间的区别,而不需要编写-- spaced - -?
style=input('Give new style ( :, --, -., -): ','s');
h(id) = plot_handles(id);
if get(h(id), 'LineStyle')==(style)
disp('The choosen style is already used!');
else
set(h(id), 'LineStyle', style);
end发布于 2013-06-10 01:22:49
当您使用==时,您将获得一个逐件比较,如下所示:
'-' == '--'
ans =
1 1尝试使用isequal:
isequal('-' ,'--')
ans =
0我认为这应该行得通:
if isequal(get(h(id), 'LineStyle'), (style))
disp('The choosen style is already used!');
else
set(h(id), 'LineStyle', style); https://stackoverflow.com/questions/17012103
复制相似问题