MATLAB: How to write equation in matlab

digital image processingdigital signal processingimage processingmathematicsMATLABmatlab codersignal processing

i have an equation and trying to write in matlab but i am not getting desired result so please help me.
please find attached file for equation and result shown in red line in figure for that equation.
i am trying like
r=1000;
c=1000;
p=32;
m=8;
for i= 1:r
for j=1:c
if mod(i/(m*p),2) %odd
SP(i,j)=-pi+round((i/p)+1)*(2*pi/m) ;
else % even
SP(i,j)=pi-round(i/p)*(2*pi/m);
end
end
end
figure(1)
plot(SP)

Best Answer

I am guessing that brackets in this case means the same as 'floor', so your code would then be something like this:
m = 8;
P = 32;
x = linspace(0,1000,5000);
SP = zeros(1,length(x));
for i = 1:length(x)
if mod(floor(x(i)/(m*P)),2) == 0
SP(i) = pi-floor(x(i)/P)*2*pi/m;
else
SP(i) = -pi+(floor(x(i)/P)+1)*2*pi/m;
end
end
plot(x,SP)
I don't know how y enters into this.