[英]Matlab) how can I plot graphs of function with various input arguments?
mfunction.m mfunction.m
function[P] = mfunction(v,M,R,T)
P=4*pi*(M/(2*pi*R*T)).^(3/2)*v.^2*exp((-M*(v.^2))/(2*R*T));
end
I want to make a graph. 我想制作一个图表。 x would be v and the range is 1: 1200
, x为v,范围为1: 1200
,
M = 0.032,R = 8.31, T= 300
and I want to plot y=mfunction(x)
我想绘制y=mfunction(x)
and errors pop up. 弹出错误。 How can I draw a graph? 我该如何绘制图表?
The problem lies at the middle multiplication 问题在于中间乘法
P=4*pi*(M/(2*pi*R*T)).^(3/2)*v.^2 * exp((-M*(v.^2))/(2*R*T));
^
What you are doing is similar to doing 你在做什么和做的很相似
[1,2] * [1,2]
, which gives you the error "mtimes Inner matrix dimensions must agree", because it is multiplying a mx1 matrix to an mx1 matrix. ,它给你错误“mtimes内部矩阵尺寸必须同意”,因为它将mx1矩阵乘以mx1矩阵。
Depending on want you need, you can do one of the following: 根据您的需要,您可以执行以下操作之一:
>> [1,2] * [1,2]' %inner product
ans =
5
>> [1,2]' * [1,2]
ans =
1 2
2 4
>> [1,2] .* [1,2] %element-wise product
ans =
1 4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.