MATLAB changing axis labes on step()/margin() functions help required please

In summary, the speaker is having trouble with a MATLAB GUI that displays a bode diagram and step response of a transfer function. They are specifically having difficulty changing the labels of the plots shown. The speaker has tried using the xlabel function, but it only replaces part of the label and not the entire thing. They have searched for a solution online but have not been successful. Suggestions for solving the problem include using the XTick and XTickLabel properties or a MATLAB function from the file exchange.
  • #1
HeZ
10
1
Hi all,

I am having a little trouble with a MATLAB GUI that i am writing, with GUIDE. Its purpose is basically to display the bode diagram and step response of a transfer function, and allow the user to change controller parameters/time delays and such to see the affect. I won't post my code here, because it works perfectly. (unless anyone wants it)

The one thing i am having trouble with is changing the labels of the plots drawn by step/margin functions. My transfer functions are actually in minutes whereas the plot automatically labels the axis as seconds.

Margin looks like: 'Frequency (rad/sec)'
Step looks like : 'Time (sec)'

I have tried using xlabel('newLabel');
However what that just replaces the 'Frequency' Label with 'newLabel', whilst the (rad/sec) component remains.
This is the same deal for the step plot.

I have googled this extensively and cannot seem to find the answer :(

Thanks in advance,
Chris
 
  • Like
Likes MMG19
Physics news on Phys.org
  • #2
you can set these two properties: XTick XTickLabel

XTICK sets where the tick marks are, the label set WHAT they are (can be text)

Now, you can write a loop with sprintf to make a series of numbers into the text you want if you want to do HH:MM:SS time.

There's also a MATLAB function on the file exchange that might help:

http://www.mathworks.com/matlabcentral/fileexchange/15986
 

Related to MATLAB changing axis labes on step()/margin() functions help required please

1. How do I change the axis labels on the step() function in MATLAB?

To change the axis labels on the step() function in MATLAB, you can use the xlabel() and ylabel() functions. For example, if you want to change the x-axis label to "Time" and the y-axis label to "Amplitude", you can use the following code: xlabel('Time') and ylabel('Amplitude').

2. Can I change the axis labels on the margin() function in MATLAB?

Yes, you can change the axis labels on the margin() function in MATLAB using the same xlabel() and ylabel() functions mentioned above. Simply specify the desired label inside the parentheses.

3. How do I add units to the axis labels on the step() and margin() functions in MATLAB?

To add units to the axis labels, you can use the text() function. For example, if you want to add the unit "m/s" to the y-axis label on the step() function, you can use the code text('Amplitude (m/s)'). This will add the desired unit in parentheses next to the label.

4. How can I change the font size and style of the axis labels on the step() and margin() functions in MATLAB?

To change the font size and style of the axis labels, you can use the set() function. For example, if you want to change the font size to 14 and the font style to bold on the x-axis label of the step() function, you can use the code set(gca, 'FontSize', 14, 'FontWeight', 'bold'). This will set the font size to 14 and the font weight to bold on the current axis (gca).

5. Can I rotate the axis labels on the step() and margin() functions in MATLAB?

Yes, you can rotate the axis labels on the step() and margin() functions in MATLAB using the xtickangle() and ytickangle() functions. For example, if you want to rotate the x-axis label on the step() function by 45 degrees, you can use the code xtickangle(45). This will rotate the x-axis label by the specified angle.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
759
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
Back
Top