how can i get 498 matrices???

1 visualizzazione (ultimi 30 giorni)
youngdong jang
youngdong jang il 4 Giu 2020
Risposto: madhan ravi il 4 Giu 2020
function y = BSSpline(x)
%Basic cubic spline function of Chapter 10, (51)
%Function built to accept vector arguments.
for i=1:length(x)
if x(i)>=0 & x(i)<=1
y(i)=((2-x(i))^3-4*(1-x(i))^3)/4;
elseif x(i)>1 & x(i)<=2
y(i)=(2-x(i))^3/4;
elseif x(i)>2
y(i)=0;
else, y(i) = BSSpline(-x(i));
end
end
n=500; h=1/(n+1);
x=linspace(0,1,n+2);
t=0:.00001:1;
for i=2:499
phi(i)=BSSpline((t-(i).*h)/h);
end
i want to get phi(2)=[ ~] , phi(3)=[ ~], .....phi(499)=[~]. my cod has error about index.
please help me.

Risposte (1)

madhan ravi
madhan ravi il 4 Giu 2020
n=500;
h=1/(n+1);
x=linspace(0,1,n+2);
t=0:1e-5:1;
phi = cell(size(t));
for ii=1:498
phi(ii)={BSSpline((t-(ii).*h)/h)};
end
% celldisp(phi)
function y = BSSpline(x)
%Basic cubic spline function of Chapter 10, (51)
%Function built to accept vector arguments.
y = zeros(size(x)); %preallocate
for ii=1:length(x)
if x(ii)>=0 && x(ii)<=1
y(ii)=((2-x(ii))^3-4*(1-x(ii))^3)/4;
elseif x(ii)>1 && x(ii)<=2
y(ii)=(2-x(ii))^3/4;
elseif x(ii)>2
y(ii)=0;
else, y(ii) = BSSpline(-x(ii));
end
end
end

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by