standard separation of x axis tick marks
4 views (last 30 days)
Show older comments
Adam Dilley
on 11 Jul 2019
Commented: Star Strider
on 11 Jul 2019
Hello,
I'm writing a program for a class that plots a transfer function to the omega(rad/s) and the phase angle to omega(rad/s) but I'm running into the problem of the graph not looking the way it needs to. below is the code i wrote so you can see what the graph currently looks like and i figured out how to label the ticks correctly but HOW DO YOU GET THE TICKS SPACED EVENLY when the the numbers are xticks([10^0 10^2 10^4 10^6])?
% Input Variable Section:
R = 10000%input('What is the resistance (in ohms)? ');
L = 1%input('What is the inductance (in henries)? ');
omega1 = 1%input('what is the starting frequency (in radians/sec)? ');
omega2 = 1000000%input('what is the ending frequency (in radians/sec)? ');
dw = (omega2-omega1)/1000;
% Parameter Section:
omega = omega1:dw:omega2;
% Calculation Section:
T = R./(L.*omega);
H = 1./(sqrt(1+(T).^2));
decibels = 20.*log10(H);
phi = atand(T);
table = [omega',T',H',decibels',phi'];
% Output Variable Section:
subplot(1,2,1)
plot(omega,decibels),xlabel('Omega (rad/s)'),ylabel('Hv'),title('High Pass RL Filter Transfer Function')
xticks([10^0 10^2 10^4 10^6])
subplot(1,2,2)
plot(omega,phi), xlabel('Omega (rad/s)'),ylabel('Phase Angle'),title('High Pass RL Filter Phase Angle')
xticks([10^0 10^2 10^4 10^6])
0 Comments
Accepted Answer
Star Strider
on 11 Jul 2019
% Output Variable Section:
subplot(1,2,1)
semilogx(omega,decibels),xlabel('Omega (rad/s)'),ylabel('Hv'),title('High Pass RL Filter Transfer Function')
xticks([10^0 10^2 10^4 10^6])
subplot(1,2,2)
semilogx(omega,phi), xlabel('Omega (rad/s)'),ylabel('Phase Angle'),title('High Pass RL Filter Phase Angle')
xticks([10^0 10^2 10^4 10^6])
Equivalently, you can use:
set(gca, 'XScale','log')
for each subplot.
2 Comments
More Answers (1)
Bobby Huxford
on 11 Jul 2019
I believe you are looking to change the scale of the X-axis to log:
set(gca, 'XScale', 'log')
Full code:
% Input Variable Section:
R = 10000%input('What is the resistance (in ohms)? ');
L = 1%input('What is the inductance (in henries)? ');
omega1 = 1%input('what is the starting frequency (in radians/sec)? ');
omega2 = 1000000%input('what is the ending frequency (in radians/sec)? ');
dw = (omega2-omega1)/1000;
% Parameter Section:
omega = omega1:dw:omega2;
% Calculation Section:
T = R./(L.*omega);
H = 1./(sqrt(1+(T).^2));
decibels = 20.*log10(H);
phi = atand(T);
table = [omega',T',H',decibels',phi'];
% Output Variable Section:
subplot(1,2,1)
plot(omega,decibels),xlabel('Omega (rad/s)'),ylabel('Hv'),title('High Pass RL Filter Transfer Function')
xticks([10^0 10^2 10^4 10^6])
subplot(1,2,2)
plot(omega,phi), xlabel('Omega (rad/s)'),ylabel('Phase Angle'),title('High Pass RL Filter Phase Angle')
set(gca, 'XScale', 'log')
xticks([10^0 10^2 10^4 10^6])
0 Comments
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!