This function does not work and gives the error in P=zeros(n) i don't understand why

1 次查看(过去 30 天)
function [P]=BULBP(x,n)
P=zeros(n);
for i=1:n
P(n)=P(n)+x(i)*Psat(i);
end
end
end

回答(3 个)

Matt J
Matt J 2013-1-12
Probably because you never define Psat.

Azzi Abdelmalek
Azzi Abdelmalek 2013-1-12
What is Psat? Why are using 3 end?
function P=BULBP(x,n)
P=zeros(1,n);
for ii=1:n
P(n)=P(n)+x(ii)*Psat(ii); % what is Psat?
end

Walter Roberson
Walter Roberson 2013-1-12
The code would give an error if n was negative or contained a fraction or an imaginary number.
Also note that if n is a scalar, then
zeros(n)
is the same as
zeros(n,n)

类别

Help CenterFile Exchange 中查找有关 Historical Contests 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by