xline issue with adding a number to the line through the labels option
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jason
el 4 de Jun. de 2024
Comentada: Aditya
el 4 de Jun. de 2024
Is there a reason why the xline (or yline) functions won't accept a number converted to a string
c=b(3); %Breakpoint
cs=num2str(c)
class(cs)
xline(ax3,c,cs);
cs =
'125.7048'
ans =
'char'
Error using xline
Invalid parameter/value pair arguments.
0 comentarios
Respuesta aceptada
Aditya
el 4 de Jun. de 2024
Hi Jason,
In MATLAB, the xline function is designed to add vertical lines to a plot and allows for customization through various parameters, including adding a label directly to the line. However, this customization needs to be done using 'Name,Value' pairs. When you attempt to pass the string representation of a number directly as an argument, without specifying it as part of a 'Name,Value' pair, MATLAB does not recognize it as a valid input, leading to the "Invalid parameter/value pair arguments" error.
To add a label to your line correctly, you need to use the 'Label' option followed by the string you wish to use as the label. Here's how you can adjust your code:
% Correct way to add Label
xline(ax3,c,'Label',cs);
I hope this clears up the confusion!
3 comentarios
Aditya
el 4 de Jun. de 2024
yes, you can specify the label this way:
xline(ax3,c,'-',cs);
You can also specify the linestyle: Specify Line and Marker Appearance in Plots - MATLAB & Simulink - MathWorks India
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!