Pascal to matlab without padarray command
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hello, how can I translate this code in matlab? I was planning to create a vector from 1 to 300, make the calculations for w1(n1>0), then increase its size to 600, shift the data and create a mirrorlike copy of it to account for the negative indices... but I got lost here it is the code
begin
l1:=70;
for n1:= 0 to round(l1/2) do
begin
w1[n1]:=cos(n1);
w1[-n1]:=w1[i1,n1];
end;
for n1:=round(l1/2)+1 to 300 do
begin
w1[n1]:=w1[round(l1/2)]*exp(-(n1-round(l1/2)));
w1[-n1]:=w1[n1];
end;
end;
end
thanks
0 comentarios
Respuestas (1)
Walter Roberson
el 28 de Jun. de 2012
l1 = 70;
half_l1 = round(l1/2);
for n1 = 0 : half_l1
w1(half_l1 + 1 + n1) = cos(n1);
w1(half_l1 + 1 - n1) = w1(i1, n1 + 1);
end
for n1 = half_l1 + 1 : 300
w1(half_l1 + 1 + n1) = w1(half_l1 + 1 + half_l1) * exp(-(n1-half_l1));
w1(half_l1 + 1 - n1) = w1(half_l1 + 1 + n1);
end
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!