matlab - 在一个屏幕上绘制两个正弦波的乘积

标签 matlab

我试图在 matlab 的一个图中绘制电路的电压、电流和功率。以下是方程式:

enter image description here

enter image description here

enter image description here

我不确定如何在 matlab 中定义 phi,它是 -3.14/4 还是弧度?如果可以,你能告诉我如何在 matlab 脚本中定义它吗?

这是我为此任务编写的代码:

t = 0: 0.1:100;
pi = 3.14;
Vmax = 10;
Imax = 1;
f = 50;
phi_default = -pi/4;

Vsrc = Vmax * sin((2*pi*f) * t);
Isrc = Imax * sin((2*pi*f) * t + phi_default);

% Psrc = Vsrc * Isrc; %
% plot(t,Vsrc, t, Isrc, t, Psrc); %
% legend('V', 'I', 'P') ;

plot(t,Vsrc, t, Isrc);
legend('V', 'I');

注释掉的行的问题是,正如您可能知道的那样,幂被定义为 V * I 所以当我想这样做时,我得到了这个错误:Inner matrix dimensions must同意。 如何解决这个问题?

谢谢!

最佳答案

Inner matrix dimensions must agree. how to fix this?

您想进行逐元素乘法,而不是矩阵乘法。

Psrc = Vsrc .* Isrc;
          __^ here

关于matlab - 在一个屏幕上绘制两个正弦波的乘积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9508490/

相关文章:

linux - 回复 : Open Matlab function from command line linux

python - Matlab -> Python。从磁盘读取异构一维二进制数组

c - C C++ 中的 matlab 和 matlab 中的 C C++

matlab - 在 Matlab 中使用不同的颜色

file - 在matlab中显示mat文件

MATLAB 的 'saveas' 将我的图形保存为正方形。但我希望它们更加矩形

json - 在 Matlab 结构体的字段名称中使用句点

python - 将Matlab的向量赋值翻译成Python形式

matlab - 获取元胞数组元素类类型的最快方法

matlab - 计算二维联合概率分布