1)Error using integral2ParseArgs (line 13)Expected a string for the parameter name,instead the input was 'double' 2)Error in integral2 (line 104) opstruct = integral2P​arseArgs(i​sImproper,​varargin{:​}); I am getting these two errors.what should bedone

5 次查看(过去 30 天)
pdf=N*exp(-N.*x);
xmin=0;
xmax=b;
ymin=0;
ymax=inf;
f=@(x,y)log(1+((Zt.*y).\(Zs.*x)+1))+log(1+((Zt.*y).\(Zi+1))).*pdf;
A= integral2(f,y,ymin,ymax,x,xmin,xmax);
  2 个评论
sathia charu
sathia charu 2018-9-8
编辑:Walter Roberson 2018-9-8
close all
clear all
clc
Pt=input('primary users transmit power:');
Ps=input('secondary users transmit power:');
Pr=input('primary user receive power:');
%{
Hs=input('secondary transmitter channel gain:');
Ht=input('primary transmitter channel gain:');
He=input('evasdropper receiver channel gain:');
Hr=input('secondary receiver channel gain:');
%}
I= input('interference temperature:');
x=0;
y=0;
z=0;
t=0;
Hs=0;
Hr=0;
Ht=0;
He=0;
sigma = 5;
for N=0:2:10
Zt= Pr.\(sigma.^2);
Zs= Ps.\(sigma.^2);
Zi= I.\(sigma.^2);
x=(mod(Hs,Hr)).^2;
y=(mod(Ht,Hr)).^2;
z=(mod(Hs,He)).^2;
t=(mod(Ht,He)).^2;
b= Zi.\Zs;
pdf=N*exp(-N.*x);
xmin=0;
xmax=b;
ymin=0;
ymax=inf;
f=@(x,y)log(1+((Zt.*y).\(Zs.*x)+1))+log(1+((Zt.*y).\(Zi+1))).*pdf;
A= integral2(f,y,ymin,ymax,x,xmin,xmax);
fun1=@(x,y) log(1+((Zt.*t).\((Zs.*z)+1)))+log(1+((Zt.*t).\(Zi(z.\x)))).*pdf;
B=integral2(fun1,y,ymin,ymax,x,xmin,xmax);
Rs=(A-B) ;
end

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2018-9-7
q = integral2(fun,xmin,xmax,ymin,ymax)
Notice that variable name is not passed as part of the bounds and that you cannot pass y boundaries before x boundaries.
Symbolic integration requires that the name of the variable be passed before the bound but numeric integration is fixed order
  1 个评论
Walter Roberson
Walter Roberson 2018-9-8
I stand by my response. You should not be passing in the variable name for integral2().
You can use
B = integral2(@(y,x) fun1(x,y), ymin, ymax, xmin, xmax)
if you need the y to be the "inner" variable for integration.
Order that the parameters vary should not matter if the bounds are fixed: it should only matter if the bounds are expressed in terms of each other. For example,
integrate fun1(x,y) over y = 0 to 5, x = 0 to sin(y)^2
then in that case the x passed into fun1 would have to be the second set of bounds because integral2 can accept functions handles for the second set of bounds but not for the first:
B = integral2(@(y,x) fun1(x,y), 0, 5, 0, @(y) sin(y).^2)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dynamic System Models 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by