how to search and match

i have 4 columns currently and I am using strfind to help find a string and print out the corresponding values . for example,
column a contains [a,b,c,d,e]
column b contains [a-1,a-2, a-3, b, c-4, c-5,...]
i would like column a to print out to the corresponding values in a, so in column a, a should be printed 3x.
how can i do this.

댓글 수: 4

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 9일
What should contain the result?
Jan
Jan 2013년 9월 9일
The data are not explained clearly. What is "a column" and what does "column a contains [a,b,c,d,e]" mean in valid Matlab syntax? Is "a" a column cell like {'a'; 'b'; 'c'; 'd'; 'e'}, or is it a double vector and "a", "b" etc are placeholders? It looks strange that "a" is used as specifier of the column and as element of the column also.
I suggest to post the inputs in valid Matlab syntax and to show an example of the wanted result with real data.
andrew
andrew 2013년 9월 9일
To clarify: i mean to say column 1, and column 2, and yes like you said Jan it should be cell column ['a','b','c', 'd',....]
the result should be: column 1 ['a','a','a'...] and in column 2 ['a-1','a-2',a-3'....]
Jan
Jan 2013년 9월 9일
편집: Jan 2013년 9월 9일
While "['a','b','c', 'd',....]" is equivalent to 'abcd', a cell would be "{'a','b','c', 'd',....}". The curly braces are important.
Do I understand correctly, that the input data is b and you want to keep only the part left from the "-" character? Which purpose has the "column 1" then?
You wrote, that you have 4 columns, but I see a description of 2 columns only (I still write column, because I'm not sure what type and dimensions these object have).

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2013년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by