What does the code below means

1 view (last 30 days)
Li LEE
Li LEE on 11 May 2015
Answered: Li LEE on 11 May 2015
ind = strfind(method,'##$PVM_NMovieFrames=');
ind = ind+20;
buff='';
n=1;
while method(ind)~= '$'
buff(n) = method(ind);
ind = ind+1;
n = n+1;
end
Question 1: why would i need a buff=' '
Question 2:why would the condition needs to have ~
  1 Comment
Adam
Adam on 11 May 2015
Edited: Adam on 11 May 2015
Can't you tell us what the purpose of the code is? Whether you need either of the things you query in your two questions is not at all obvious without understanding what the intent of the code is.
buff = ''
looks superfluous, but you can easily find out by removing it. If you get an error then it is clearly needed as initialisation..
~ means NOT so the loop is presumably supposed to end when method(ind) is a '$'.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 11 May 2015
You need the initialization because method(ind) might be equal to '$' immediately.

More Answers (1)

Li LEE
Li LEE on 11 May 2015
hi adam, thank you for your answer. I was trying to understand how the code works.This code was written by someone else. the code is suppose to read a parameter named PVM_NMovieFrames. By you answering my question regarding what is ~, i figured it out. the buff=' ', the code was trying to create an empty array or string.
thanks

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!