I want to create a matlab program to perform this operation and show the result in each operation in table

4 views (last 30 days)
X(i)=sumation of x(i-k)*f(k) Where i=1:200,k=1:i,f(k) is a function
  21 Comments
Walter Roberson
Walter Roberson on 11 Jul 2021
for t=2:200
sum=0
for j=2:t
sum=sum+sum(t-j).*f(j)
end
v(t)=sum
end
t starts at 2. j starts at 2. t-j starts at 0. sum starts at the scalar 0. sum(t-j) would be sum(0) which is an invalid index.
The associated logic never stores more than 1 value in sum so sum can only be indexed at 1 (or true)
Reminder that matlab does not support implied multiplication. If you want multiplication then you need to use a multiplication operator.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 29 Jun 2021
x = @(K) pi*exp(-(K-3).^2);
a = rand();
b = rand();
bounds = sort(rand(1,2))
bounds = 1×2
0.2767 0.5438
pd = makedist('Weibull','a',a,'b',b);
pdd = truncate(pd, bounds(1), bounds(2))
pdd =
WeibullDistribution Weibull distribution A = 0.500496 B = 0.36551 Truncated to the interval [0.276723, 0.543765]
f = @(k) cdf(pdd, k)
f = function_handle with value:
@(k)cdf(pdd,k)
for i = 1 : 200
itotal = 0;
for k = 1 : i
itotal = itotal + x(i-k)*f(k);
end
X(i) = itotal;
end
X
X = 1×200
0.0004 0.0579 1.2137 4.3552 5.5110 5.5685 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689
  7 Comments
Maha Ahmed
Maha Ahmed on 1 Jul 2021
Edited: Walter Roberson on 1 Jul 2021
f=@(t) (al/b)*k*(t.^(k-1)).*exp(-((t.^k)/b))+(1-al)*(1/(at*sig*(2*pi)^.5)).*exp(-(t-mu).^2/(2*(sig.^2)))

Sign in to comment.

More Answers (2)

Mahaveer Singh
Mahaveer Singh on 13 Jul 2021
S=0;
x(1)=0; % initial value of x.
for i=2:1:200
for k=1:1:i-1
S(k)=x(i-k).*f(k);
end
x(i)=sum(S);
end
sumation=x

Sara Boznik
Sara Boznik on 27 Jun 2021
part=0;
sumation=0;
for i=1:1:200
for k=1:1:i
part=x(i-k).*f(k)
sumation=sumation+part
end
end
Sumation is x(i).
  4 Comments
Maha Ahmed
Maha Ahmed on 27 Jun 2021
f(k) is weibull trankated normal distribution function ,all parameters are known, k is the only variable Alfa(i)=sumation of (alfa(i-k)*f(k)), these sumation from k=1tok=i, and i=1to 200

Sign in to comment.

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!