Error using double Conversion to double from cell is not possible.
이전 댓글 표시
Hi, Im facing this problem can some one help? I want to store multiple elements of matrix 'Rulebase' to 'a'
Rulebase = { 'OutNB' 'OutNB' 'OutNB' 'OutNM' 'OutNS' 'OutNS' 'OutZ';
'OutNB' 'OutNM' 'OutNM' 'OutNM' 'OutNS' 'OutZ ' 'OutPS';
'OutNB' 'OutNM' 'OutNS' 'OutNS' 'OutZ' 'OutPS' 'OutPM';
'OutNB' 'OutNM' 'OutNS' 'OutZ ' 'OutPS' 'OutPM' 'OutPB';
'OutNM' 'OutNS' 'OutZ' 'OutPS' 'OutPS' 'OutPM' 'OutPB';
'OutNS' 'OutZ' 'OutPS' 'OutPM' 'OutPM' 'OutPM' 'OutPB';
'OutZ' 'OutPS' 'OutPS' 'OutPM' 'OutPB' 'OutPB' 'OutPB'};
a=zeros(1,7);
a(1,1)=Rulebase(2,3);
a(1,2)=Rulebase(2,4);
.
.
.
..
Output = a;
Where Output should be like.. OutNB OutNS OutZ..... and want to access 'Output' later for other purpose (Character Comparison).Please Help
채택된 답변
추가 답변 (1개)
KSSV
2016년 11월 10일
You can extra
ct the required string from the cell array using:
clc; clear all ;
Rulebase = { 'OutNB' 'OutNB' 'OutNB' 'OutNM' 'OutNS' 'OutNS' 'OutZ';
'OutNB' 'OutNM' 'OutNM' 'OutNM' 'OutNS' 'OutZ ' 'OutPS';
'OutNB' 'OutNM' 'OutNS' 'OutNS' 'OutZ' 'OutPS' 'OutPM';
'OutNB' 'OutNM' 'OutNS' 'OutZ ' 'OutPS' 'OutPM' 'OutPB';
'OutNM' 'OutNS' 'OutZ' 'OutPS' 'OutPS' 'OutPM' 'OutPB';
'OutNS' 'OutZ' 'OutPS' 'OutPM' 'OutPM' 'OutPM' 'OutPB';
'OutZ' 'OutPS' 'OutPS' 'OutPM' 'OutPB' 'OutPB' 'OutPB'};
%
idx = strfind(Rulebase(:), 'OutNB');
idx = find(not(cellfun('isempty', idx)));
Rulebase(idx)
댓글 수: 2
Guillaume
2016년 11월 10일
Why not simply
Rulebase(strcmp(RuleBase, 'OutNB')) %for full match
or
Rulebase(contains(RuleBase, 'OutN')) %for partial match
Sarit Hati
2016년 11월 11일
카테고리
도움말 센터 및 File Exchange에서 Modulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!