필터 지우기
필터 지우기

how to create matrix of string and use it in mathematic operation?

조회 수: 1 (최근 30일)
eri
eri 2012년 10월 24일
example
a=[1;0;1;1;0]
b=[ben;james;mike;ralph;will]
c=a.*b
c=[ben;mike;ralph]

채택된 답변

Matt J
Matt J 2012년 10월 24일
편집: Matt J 2012년 10월 24일
Use a cell array of strings for b and use logical indexing instead of a.*b,
>> b={'ben';'james';'mike';'ralph';'will'};
>> a=logical([1;0;1;1;0]);
>> b(a)
ans =
'ben'
'mike'
'ralph'

추가 답변 (1개)

Matt J
Matt J 2012년 10월 24일
편집: Matt J 2012년 10월 24일
Speaking of mathematical operations with strings, ever wonder what you get when you cross a cat with an owl?
>> cross('cat','owl')
ans =
-3328 2184 1014

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by