필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

About Cell arrays access

조회 수: 1 (최근 30일)
Kleber Zuza Nobrega
Kleber Zuza Nobrega 2016년 4월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
I have the following question... Suppose I have a cell array given by:
a{1}={'teste' 4},
a{2}={'meste' 5},
a{3}={'zeste' 6},
How could I have access to the letters 't' 'm' and 'z' at the same time. It means, I would like a command line in terms of () [] and {} in such a way I could get these letters (or the numbers!!) and save them in a new variable.

답변 (1개)

Jos (10584)
Jos (10584) 2016년 4월 6일
a{1}={'teste' 4},
a{2}={'meste' 5},
a{3}={'zeste' 6},
B = cellfun(@(x) x{1}(1),a)
  댓글 수: 2
Kleber Zuza Nobrega
Kleber Zuza Nobrega 2016년 4월 6일
Actually, I would like to do it withtou cellfun... using only : () [] {}. But Thank you so much anyway
Walter Roberson
Walter Roberson 2016년 4월 7일
You cannot do it with just () [] {}. You need some form of iteration, or you need at least one anonymous function to help, or you need to assign to at least one variable. (I have been able to do it with two temporary assignments.)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by