how to write equation in matlab ?
2 次查看(过去 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
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
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
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!