- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 LaTex 字符串为 y 轴标签插入一个分数,并且我得到了一个数字(以标准字体和 ylabel
位置)以及我所期望的(我要插入的分数)。当我编辑代码时,这对我来说已经改变了,但是一旦我尝试调查它就停止了(我输入时它是 353.191,以防它有帮助)。如果我不尝试在 y 轴上添加标签,或者在没有 LaTex 的情况下添加标签,则数字不存在。没有错误信息。
有问题的代码:
ylabel(text('Interpreter','LaTex',...
'string','$\frac{\tau_b(t)}{\phi \bar{U}}$',...
'FontSize',20,'position',[-1.25,0.2]));
完整程序(以上代码是程序结束前的代码):
% --- MM3CAI Coursework 1 ---
clear all; clf('reset'); clc;
fig_num=0;
disp('Started program');
disp(' ');
% --- Task 1. About the water-brake only ---
disp('Started task 1');
disp(' ');
w_t=0.003; % Volume of water in the brake at time t [m^3]
thet_t=250; % Angular velocity of brake at time t [rads^-1]
percent=0.1; % Percent added to values for small change [%]
fraction=percent/100;
del_w=w_t*fraction;
del_t=thet_t*fraction;
w_del=w_t+del_w;
thet_del=thet_t+del_t;
clear percent fraction;
% --- Q1 ---
disp('Started question 1');
disp(' ');
tau =150*w_t *thet_t;
tau_w=150*w_del*thet_t;
tau_t=150*w_t *thet_del;
tau_mat=[tau;...
tau_w;...
tau_t];
A=[w_t thet_t 1;...
w_del thet_t 1;...
w_t thet_del 1];
variables_mat=A\tau_mat;
phi=variables_mat(1,1);
psi=variables_mat(2,1);
eta=variables_mat(3,1);
disp(['Phi = ', num2str(phi)]);
disp(['Psi = ', num2str(psi)]);
disp(['Eta = ', num2str(eta)]);
disp(' ');
disp('Finished question 1');
disp('----------');
% --- Q2 ---
disp('Started question 2');
disp(' ');
beta=-eta/phi;
disp(['Beta = ', num2str(beta)]);
disp(' ');
disp('Finished question 2');
disp('----------');
% --- Q4 ---
disp('Started question 4');
disp(' ');
G=@(omega) phi./(1+(5i.*omega));
frequency=logspace(-3,3,700)';
G_mat=G(frequency);
phase_mat_rad=angle(G_mat);
phase_mat_deg=phase_mat_rad.*(180/pi);
magnitude_mat=abs(G_mat);
gain_mat=20.*log10(magnitude_mat);
fig_num=fig_num+1;
figure(fig_num);
subplot(2,1,1);
semilogx(frequency,gain_mat);
title('Bode Plot');
xlabel('Frequency [rads^-^1]');
ylabel('Gain [dBs]');
subplot(2,1,2);
semilogx(frequency,phase_mat_deg);
xlabel('Frequency [rads^-^1]');
ylabel('Phase Angle [degrees]');
disp('Finished question 4');
disp('----------');
% --- Q5 ---
disp('Started question 5');
disp(' ');
U_bar=1;
step=@(t) (phi*U_bar)*(1-exp(-t/5));
time=(0:0.01:8);
step_mat=step(time);
normalised=step_mat./(phi*U_bar);
fig_num=fig_num+1;
figure(fig_num);
plot(time,normalised);
title('Step Response');
xlabel('Time [s]');
ylabel(text('Interpreter','LaTex',...
'string','$\frac{\tau_b(t)}{\phi \bar{U}}$',...
'FontSize',20,'position',[-1.25,0.2]));
disp('Finished question 5');
disp('----------');
我真的很困惑,这让我很难找到任何东西。我所能找到的只是关于使用 LaTex 的基本 MatLab 帮助(这就是我将字符串混淆在一起的方式)以及人们遇到 text()
无法正常工作并产生错误的问题 - 没有预期输出生成了并且出现了其他东西。
最佳答案
TEXT 函数返回文本对象的句柄,实际上是一个数字。这是您作为 y 标签获得的数字。您只需将字符串作为第一个参数传递给 YLABEL 并指定 Interpreter
(和 FontSize
)属性:
ylabel('$\frac{\tau_b(t)}{\phi \bar{U}}$','Interpreter','LaTex','FontSize',20);
位置由 ylabel
自动确定。
在您的 ylabel
语句中,实际上创建了文本对象(这就是您没有收到错误的原因),但是选择的位置使得文本位于可见区域之外. -1.25 表示文本位于左侧坐标轴大小的 1.25 处。
您也可以使用文本对象作为轴标签,但您必须随着轴大小的变化调整文本位置。
text('Interpreter','LaTex',...
'string','$\frac{\tau_b(t)}{\phi \bar{U}}$',...
'FontSize',20,'position',[-0.1,0.5]);
注意,Position
属性不是x
和y
,而是轴分数。
关于matlab - 我试图在 MATLAB 中使用 LaTex 字符串作为轴标签,但没有明显的原因得到一个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9548895/
通常当我请求线程转储时,系统性能不佳的症状很容易解释;也就是说,通常我会看到许多线程显然正在等待一个已被获取但未被另一个释放的监视器。 在这种情况下,我有很多线程在等待监视器 (0x965ad100)
C:\Users\shagy\Desktop\3RD YEAR 2ND SEMESTER\SPM\Newfolder\SPM-SMS>npm start npm ERR! path C:\Users\
我是一名优秀的程序员,十分优秀!