필터 지우기
필터 지우기

if strcmp(method,'range')

조회 수: 44 (최근 30일)
mina
mina 2013년 3월 2일
댓글: SUDEEP KUMAR DHURUA 2018년 3월 25일
i have the following codes : but want know that in line 2,range word what mean?
function data=data_normalize(data,method)
if strcmp(method,'range')
data=(data-repmat(min(data),size(data,1),1))./(repmat(max(data),size(data,1),1)-repmat(min(data),size(data,1),1));
elseif strcmp(method,'var')
data=(data-repmat(mean(data),size(data,1),1))./(repmat(std(data),size(data,1),1));
else
error('Unknown method given')
end
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 2일
Mina, from your previous question, I think that you should read the basics of Matlab
SUDEEP KUMAR DHURUA
SUDEEP KUMAR DHURUA 2018년 3월 25일
https://in.mathworks.com/help/matlab/ref/strcmp.html go to this link and you will understand it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Wayne King
Wayne King 2013년 3월 2일
편집: Wayne King 2013년 3월 2일
Mina welcome to MATLAB! I think Azzi has some good advice. If you invest some time in reading the MATLAB documentation, you will help yourself learn.
For example, if you enter
>>help strcmp
at the command prompt, you get
"strcmp Compare strings.
TF = strcmp(S1,S2) compares the strings S1 and S2 and returns logical 1
(true) if they are identical, and returns logical 0 (false) otherwise."
You can also get help with
>>doc strcmp
For your example, this means that if the method input argument is 'range'
method = 'range';
strcmp(method,'range')
returns a 1 because method and 'range' are equal while
strcmp(method,'var')
returns a 0 because method and 'var' are not equal.
When coupled with an if statement, a 1 means that the statement is true and the code in the if statement will execute
if strcmp(method,'range')
disp('hi');
elseif strcmp(method,'var')
disp('bye');
else
disp('error');
end
In the above, since the first strcmp() is equal to 1, the text 'hi' is displayed.
  댓글 수: 2
mina
mina 2013년 3월 2일
ok.thanks
MOHD Zubair
MOHD Zubair 2018년 3월 8일
good explanation

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by