## standard separation of x axis tick marks

さんによって質問されました 2019 年 7 月 11 日

### Star Strider (view profile)

さんによって コメントされました 2019 年 7 月 11 日
Star Strider

### Star Strider (view profile)

さんの 回答が採用されました
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 件のコメント

サインイン to comment.

## 2 件の回答 ### Star Strider (view profile)

2019 年 7 月 11 日
採用された回答

Plot them using semilogx:
% 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 件のコメント

2019 年 7 月 11 日
Thank you so much! I looked this up in our text book and its not covered until our next chapter, I don't know why we had an assignment that needed this plot function before we covered it. It worked though, thanks again.
Star Strider

### Star Strider (view profile)

2019 年 7 月 11 日
As always, my pleasure!

サインイン to comment.

### Bobby Huxford (view profile)

2019 年 7 月 11 日

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 件のコメント

サインイン to comment.