How do i set the marker and line commands to accept the symbols as inputs
1 次查看(过去 30 天)
显示 更早的评论
p.LineStyle = input('Select which line style you would like: ','s');
while p.LineStyle ~= ('''-''' | '''--''' | ''':''' | '''-.''' | '''none''')
p.LineStyle = input('Refer to the PDF document for valid inputs: ');
end
I get the error 'Matrix dimensions must agree'
1 个评论
Walter Roberson
2018-11-2
Note that if p is a Mathworks graphics object, then setting p.LineStyle to something invalid would error before getting to the while. That is why I store into a different variable and leave the setting of p.LineStyle until after the input has been validated.
采纳的回答
Star Strider
2018-11-2
编辑:Star Strider
2018-11-2
This works for me:
p.LineStyle = input('Select which line style you would like: ','s');
while ~strcmpi(p.LineStyle, {'''-''' , '''--''' , ''':''' , '''-.''' , '''none'''})
p.LineStyle = input('Refer to the PDF document for valid inputs: ');
end
0 个评论
更多回答(3 个)
Walter Roberson
2018-11-2
valid_styles = {'-', '--', ':', '-.', 'none'};
while true
LineStyle = input('Select which line style you would like: ','s');
if ismember(LineStyle, valid_styles)
p.LineStyle = LineStyle;
break;
end
fprintf('valid styles are: %s\n', strjoin(valid_styles, ' '));
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!