使用matlab进行错误绘图功能 [英] error plotting function using matlab

查看:98
本文介绍了使用matlab进行错误绘图功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制函数,但收到错误消息,并且由于我是新手,所以我不知道如何解决它.

I'm trying to plotting a function but I receive an error and since I'm a newbie I don't know how to fix it.

 f=-10:0.001:10;
 >> w=1/sqrt(4+(2*pi*f)^2);
 ??? Error using ==> mpower
 Inputs must be a scalar and a square matrix.
 To compute elementwise POWER, use POWER (.^) instead.

哪里出了错?

推荐答案

^矩阵的幂运算符mpower.语法A^n尝试将(方)矩阵A提高到第n次幂.如果A不是方阵(在您的示例中,它是一个向量),则显然将失败.

^ is the matrix power operator, mpower. The syntax A^n attempts to raise the (square) matrix A to the nth power. This will obviously fail if A is not a square matrix (in your example, it is a vector).

由于您的用户名包括eng,并且您正在发布有关MATLAB的信息,因此我假设您是一名工程专业的学生-您的数学入门课程应涵盖矩阵数学,以及为什么只为平方A定义A * A

Since your username includes eng and you're posting about MATLAB, I assume that you are an engineering student - your introductory math course should have covered matrix math, and why A * A is only defined for square A.

A.^n一样,您实际上需要标量运算符.^.这会将A的每个元素提高到n次幂.

You actually want the scalar operator .^, as in A.^n. This raises each element of A to the nth power.

这篇关于使用matlab进行错误绘图功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆