Matlab problem I have some code written but Im not sure if I

Matlab problem: I have some code written, but I\'m not sure if I\'m going in the right direction:

Code:

k = [-10:0.01:-3.01 -2.99:0.01:2.99 3.01:0.01:10];

ram_num = [10 500 1000 1500 10000];

tic
for z_num = ram_num

for a = 1:length(z_num)
g_num = cos(3*pi*k).^exp(-2*abs(k));
sum(a);
end
  
for b = 2:length(z_num)
g_num = cos(3*pi*k).^exp(-2*abs(k));
sum(b);
end
  
for c = 3:length(z_num)
g_num = cos(3*pi*k).^exp(-2*abs(k));
sum(c);
end
  
for d = 4:length(z_num)
g_num = cos(3*pi*k).^exp(-2*abs(k));
sum(d);
end
  
for e = 5:length(z_num)
g_num = cos(3*pi*k).^exp(-2*abs(k));
sum(e);
end
end
toc
  
%plot(
%xlabel(\'Iteration\')
%ylabel(\'Time\')

Solution

Yes it is the right way and u can continue to get the results. My suggestion is to check the code regularly using command window by giving dummy variables and known results

Matlab problem: I have some code written, but I\'m not sure if I\'m going in the right direction: Code: k = [-10:0.01:-3.01 -2.99:0.01:2.99 3.01:0.01:10]; ram_n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site