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

 採用された回答

Adam
Adam 2016 年 11 月 10 日

2 投票

a=zeros(1,7);
declares an array of type 'double'. You are trying to put strings in it.
Use
a = cell(1,7);
a{1} =Rulebase(2,3);
...
if you want to store elements of your Rulebase array..

1 件のコメント

Sarit  Hati
Sarit Hati 2016 年 11 月 11 日
Thank you Adam!! Really appreciate this!

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2016 年 11 月 10 日

1 投票

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
Guillaume 2016 年 11 月 10 日
Why not simply
Rulebase(strcmp(RuleBase, 'OutNB')) %for full match
or
Rulebase(contains(RuleBase, 'OutN')) %for partial match
Sarit  Hati
Sarit Hati 2016 年 11 月 11 日
Thank you @KSSV and @Guillaume !!. But what I was looking for Ive already got it ,thanks to @Adam!! Really appreciate you guys!!

サインインしてコメントする。

カテゴリ

質問済み:

2016 年 11 月 10 日

コメント済み:

2016 年 11 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by