convert signal curve into straight line

2 次查看(过去 30 天)
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 个评论
Evan Weking
Evan Weking 2016-11-22
sorry about that,
this is my data for the program
i'm really sorry for before, thanks

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-11-22
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.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by