绘图时内部矩阵尺寸误差必须一致 [英] Inner matrix dimensions error must agree error when plotting
本文介绍了绘图时内部矩阵尺寸误差必须一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试绘制函数:f(x)= x * e ^(x)* cos(x)从0到2 * pi.我试过跑步:
I'm attempting to plot the function: f(x) = x * e^(x) * cos(x) from 0 to 2*pi. I've tried running:
x = 0:pi/100:2*pi;
y = x*exp(x)*cos(x)
但是,每次我尝试设置y时. Matlab向我抛出使用*出错",并说内部矩阵尺寸必须一致.为什么会发生这种情况的任何见解?
However, every time I attempt to set y. Matlab throws me a 'Error using *' and says Inner matrix dimensions must agree. Any insight into why this happens?
推荐答案
您必须使用.*
(逐元素乘法),而不是*
(矩阵乘法)
You have to use .*
(element-wise multiplication), not *
(matrix multiplication)
这篇关于绘图时内部矩阵尺寸误差必须一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文