how to write equation in matlab ?

3 次查看(过去 30 天)
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)
  2 个评论
Walter Roberson
Walter Roberson 2017-11-17
In mathematics, [] indicates grouping, but does not indicate rounding unless the paper defines it as rounding. The related symbols
_ _
| x | |_ x _|
are ceiling and floor, but [ ] is not generally rounding.
Walter Roberson
Walter Roberson 2017-11-17
I have sometimes seen [A\B] notation used to indicate the size of the equivalence class of A induced by B . In graph theory it could have to do with the something about the number of vertices or edges in a graph in which B had been removed.

请先登录,再进行评论。

采纳的回答

Roger Stafford
Roger Stafford 2017-11-17
编辑:Roger Stafford 2017-11-17
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.
  4 个评论
Roger Stafford
Roger Stafford 2017-11-17
编辑:Roger Stafford 2017-11-17
Added Note: My computer doesn't generate the plot shown in your image.png. Either something is wrong with the given formula, or my interpretation of the bracket symbols is in error. The image's blue curve is just the sort of function that is needed to make the needed correction to the given formula to get the orange curve, so I suspect the trouble lies with the formula.
ajeet verma
ajeet verma 2017-11-17
编辑:ajeet verma 2017-11-17
here two curve blue and orange obtained from two different equations are shown in one figure as attached. i reattach the equations in which equation 6 for orange color and equation 7 is for blue color. so i am able to create code for blue color but problem is in orange color curve. please find attached file code for blue curve
%% stair phase-2 clc; clear all; r=1024; p=256; m=1; n=4; for i= 1:r SP2(i) = pi-floor(i/(m*p))*(2*pi/n); end plot(SP2,'b')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by