how to write equation in matlab ?

2 visualizzazioni (ultimi 30 giorni)
ajeet verma
ajeet verma il 17 Nov 2017
Modificato: ajeet verma il 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 Commenti
Walter Roberson
Walter Roberson il 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 il 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.

Accedi per commentare.

Risposta accettata

Roger Stafford
Roger Stafford il 17 Nov 2017
Modificato: Roger Stafford il 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 Commenti
Roger Stafford
Roger Stafford il 17 Nov 2017
Modificato: Roger Stafford il 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 il 17 Nov 2017
Modificato: ajeet verma il 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')

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by