Info

此问题已关闭。 请重新打开它进行编辑或回答。

Cell Array of Strings function help

1 次查看(过去 30 天)
krushnasamy subramaniyan
关闭: Walter Roberson 2015-6-15
Write a function called censor whose first input argument is a cell vector (row or column) of strings and whose second input argument is a string. It removes each element of the cell vector whose string is either identical to the second input argument ... (PLEASE FINISH THIS STATEMENT HERE)
function mystr=censor(str,substr)
str={str};
element=substr;
str(strcmp(str,element))='';
for i=1:length(str)
if iscell(str{i})
str{i}(strcmp(str{i},element))='';
end
end
  3 个评论
James Tursa
James Tursa 2015-6-6
编辑:James Tursa 2015-6-6
I have edited your question and moved the title inside the question itself. It looks incomplete, so please edit and replace my TEXT above with the remaining question, and then tell us what specific problems you are having. Then we can help you. E.g., does it give you an error (if so, post the entire error for us to see), does it give you wrong results, etc.
Thanks for making an effort and posting your attempt.
dpb
dpb 2015-6-6
Is this not the duplicate of http://www.mathworks.com/matlabcentral/answers/221886 where you've been given several hints that haven't followed up on?
As noted there, the substitution for the string in the cell is NOT the proper operation with which to begin per the problem statement as given in one of the follow-ups at that thread.
Continue the conversation in one thread only, please...

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by