how can i convert from one value to multi values
Ältere Kommentare anzeigen
how can i replace value of
alpha = 0.5
by multi values as
alpha =[0.1 0.3 0.5 0.6 0.66 0.9 1]
in the following code:
alpha = 0.5;
u0 = 0;
a_k = @(k) (k + 1)^(1 - alpha) - (k)^(1 - alpha);
n = 100;
a = 0;
b = 1;
h = (b - a) / n;
t = a:h:b;
f = @(t,u) (-u.^4) + (gamma(2*alpha+1) ./ gamma(alpha+1) ) .* (t.^alpha) - ...
(2./gamma(3 - alpha) ) .* (t.^(2 - alpha)) + (t.^(2*alpha) - t.^2).^4;
up = zeros(1, n);
uc = zeros(1, n);
zp = zeros(1, n);
uc = zeros(1, n); % ??? is this your "u"?
C = gamma(2 - alpha) * h ^ alpha;
for ni = 1:n
up(ni) = a_k(ni - 1) * u0;
for k = 1:ni - 1
up(ni) = up(ni) + (a_k(ni - 1 - k) - a_k(ni - k)) * uc(k);
end
zp(ni) = C * f(t(ni), up(ni));
uc(ni) = up(ni) + C * f(t(ni), up(ni) + zp(ni));
end
fprintf('%g\n', up(1:20))
2 Kommentare
Muhammad Usman Saleem
am 19 Jun. 2022
try to use intp1 functio in matlab
work wolf
am 20 Jun. 2022
Akzeptierte Antwort
Weitere Antworten (1)
Ayush Kumar Jaiswal
am 19 Jun. 2022
Bearbeitet: Ayush Kumar Jaiswal
am 19 Jun. 2022
You want to calculate that function at different values of alpha, it can done using
arrayfun (func, arr);
1 Kommentar
work wolf
am 20 Jun. 2022
Kategorien
Mehr zu Modify Image Colors finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!