-
MATLAB 绘图如何创建多个legend
- 将legend设置成string array
legendx(Order_PADE+1,:) = ['Loop Gain of ', num2str(Order_PADE), '-order pade approximation']
- 将legend设置成string array
-
matlab 如何将多个不同长度的字符串保存在同一个数列中
strvcat
legend_comparison = strvcat(legend_comparison, x);
-
matlab 如何显示指定位数的数字
fprintf(’%07.4f\n’,w_n) -
simulink如何内嵌变量初始化指令
- files-Model Properities - Model Properties - call backs - InitFcn*
-
global 变量在simulink中的使用(以PID程序为例)
- global可以保存当前m-function变量的值一直到下个计算周期,实现数据的寄存
- 变量的声明
function y = fcn(u) % PI program global Inte_d Kp = 7; Ki = 1e-3; % Ki = 0; error = u; Inte_d = Inte_d + error; y = Kp*error + Ki*Inte_d;
- 告知matlab function模块此处有global变量
matlab function程序的editor页面 - editor data - add data - 添加声明的global变量, scope类型设置为Data Store Memory - apply - 告知simulink这里有数据寄存的需求
添加DataStoreMemory模块 - Data Store Name填写声明的global变量名 - Signal Attributes - Signal Type real - apply - 完成
-
如何带syms函数转化为数值函数
利用 matlabFunction 将syms表达式转化为函数句柄s = 1j*2*pi*f_s Z_r = s*L_r + 1/s/C_r Z_r = matlabFunction(Z_r) % 将syms转化为句柄 Z_r(0.5 * f_r) % 直接调用即可 Z_r(1.5 * f_r)
-
绘制三维图
mesh(x, y, z)z是矩阵,得到z的值需要进行循环运算。如何提高嵌套的效率呢?尽量用矩阵计算,避免for循环。
-
simulink摆脱连线式的示波器,让你的仿真看起来无比简洁
使用到floating scopefloating scope - signal selector - 在这个界面中添加选中自己希望看到的波形的信号线 还没完,这个时候,选中的信号线并不能记录数据。在被选中的信号线上面单击,出现...,点击 enable data logging 。大功告成
-
在绘图时,如何将两条曲线之间的空间进行填充?
y1 = matlabFunction(4*D_phi*(1-D_phi)*(1-2*D_phi)); y2 = matlabFunction(4*D_phi*(1-D_phi)/(1-2*D_phi)); x = 0:1e-3:0.49999 y1 = y1(x); y2 = y2(x); figure(2) hold on plot(x, y1); plot(x, y2); ylim([0, 2]) maxY = max([y1; y2]) minY = min([y1; y2]) yFill = [maxY, fliplr(minY)]; xFill = [x, fliplr(x)]; % fliplr函数:左右翻转 fill(xFill, yFill, 'c'); for k_value = [0.5, 1, 1.5] y = matlabFunction(subs(P_ostar, k, k_value)) fplot(y, [0, 0.5]) end hold off
-
进行plecs仿真的时候,如何添加器件模型
-
pulse delay 输出不了脉冲
zero crossing options -> algorithm -> nonadaptive
Jimmy的MATLAB 调试记录
最新推荐文章于 2023-02-11 14:35:52 发布