How do i set the marker and line commands to accept the symbols as inputs
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Adam Luckman
el 2 de Nov. de 2018
Comentada: Walter Roberson
el 2 de Nov. de 2018
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 comentario
Walter Roberson
el 2 de Nov. de 2018
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.
Respuesta aceptada
Star Strider
el 2 de Nov. de 2018
Editada: Star Strider
el 2 de Nov. de 2018
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 comentarios
Más respuestas (3)
Walter Roberson
el 2 de Nov. de 2018
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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!