Input string to a matrix or a cell
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ly
am 9 Jul. 2016
Kommentiert: per isakson
am 10 Jul. 2016
Hi,
I have a string and want to input it to a matrix or a cell.
string: name
matrix: A(2,3)
cell: data{2}(2,4);
Could you help?
2 Kommentare
Akzeptierte Antwort
per isakson
am 10 Jul. 2016
Bearbeitet: per isakson
am 10 Jul. 2016
Cell array
>> data = cell( 1, 3 );
>> data{2} = cell(3,6);
>> data{2}{2,4} = 'Hello World';
or
>> data{2}(2,4) = {'Hello World'};
With a Matrix it is not practical. "A(2,3)" would address one character.
3 Kommentare
per isakson
am 10 Jul. 2016
Replace
data{1}(1,1) = 212;
by
data{1}(1,1) = {212};
per isakson
am 10 Jul. 2016
- Have you thought of using Create and Work with Tables? (Introduced in R2013b)
- See Access Data in a Cell Array
- and by the way, see The XY Problem
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!