Filter löschen
Filter löschen

how to write equation in matlab ?

3 Ansichten (letzte 30 Tage)
ajeet verma
ajeet verma am 17 Nov. 2017
Bearbeitet: ajeet verma am 17 Nov. 2017
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 Kommentare
Walter Roberson
Walter Roberson am 17 Nov. 2017
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 am 17 Nov. 2017
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 17 Nov. 2017
Bearbeitet: Roger Stafford am 17 Nov. 2017
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 Kommentare
Roger Stafford
Roger Stafford am 17 Nov. 2017
Bearbeitet: Roger Stafford am 17 Nov. 2017
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 am 17 Nov. 2017
Bearbeitet: ajeet verma am 17 Nov. 2017
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')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by