convert signal curve into straight line

4 visualizzazioni (ultimi 30 giorni)
Evan Weking
Evan Weking il 22 Nov 2016
Risposto: Walter Roberson il 22 Nov 2016
hello everyone
i want to ask something
i have signal plot like this
from this plot, i want to convert the curve into straight line with this formula : 1/√f
here is my code :
global X;
global R;
R = plot(B, A);
X = gca;
global freq;
global point;
X.Scale = 'log';
int X p1 p2;
double( 'froot(116)' )
freq('116')
val('116')
point('116');
double val1 val2; result; %#ok<VUNUS,NODEF>
for X = 0
X < 116 -1; %#ok
for R = 0 : 116 -1;
froot(X) = 8e-3 + (100e-3)/116.0*X; %#ok<AGROW>
freq(X) = (1.0/froot(X))*(1.0/froot(X));
point(X) = 116.0*freq(X)/20000.0; %#ok<AGROW>
p1 = trunc(int(point(X)));
p2 = p1+1;
val1 = val(p1);
val2 = val(p2);
result = val1+(val2-val1)/(p2-p1)*(point(X)-p1); %#ok<NASGU>
end
end
guidata(hObject,handles);
axes(handles.axes3); %#ok
plot(R);
msgbox('Transform SUCCESSFUL !');
please tell me if my code is wrong or not.
thanks
  3 Commenti
Evan Weking
Evan Weking il 22 Nov 2016
sorry about that,
this is my data for the program
i'm really sorry for before, thanks
Star Strider
Star Strider il 22 Nov 2016
That’s you .m file, not your data.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 22 Nov 2016
int X p1 p2;
in MATLAB means the same as
int('X', 'p1', 'p2')
which would attempt to find a function int that took character strings as input. It probably would not find one.
double( 'froot(116)' )
means to take the string 'froot(116)' and convert each character into its numeric encoding, such as 'f' being character #102. Then, the result of that conversion would be displayed because there is no semi-colon on the end of the line.
double val1 val2; result; %#ok<VUNUS,NODEF>
would be the same as
double('val', 'val2');
result;
which would get you an error message because double() only expects on argument.
freq('116')
would attempt to index the variable freq at [49, 49, 54] and display the result.
All in all, I think it likely that your code is in error. It appears that you attempted to convert from some other programming language.

Community Treasure Hunt

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

Start Hunting!

Translated by