Input string to a matrix or a cell

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 commentaires

Azzi Abdelmalek
Azzi Abdelmalek le 9 Juil 2016
Your question is not clear
ly
ly le 10 Juil 2016
I want to input string to position (2,3) of matrix A and position (2,4) of cell data{2}.
You can see in attached figure.

Connectez-vous pour commenter.

 Réponse acceptée

per isakson
per isakson le 10 Juil 2016
Modifié(e) : per isakson le 10 Juil 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 commentaires

ly
ly le 10 Juil 2016
Modifié(e) : per isakson le 10 Juil 2016
It works well.
But I have another.
This is the cell I want to input.
I try with:
data{1}(1,1) = 212;
data{1}(2,1) = {'Number'};
data{1}(2,2) = {'Time:'};
But "Conversion to double from cell is not possible."
If I try with :
data{1}(2,1) = {'Atom.'};
data{1}(2,2) = {'Timestep:'};
Then it run well.
How to input value and string like this Figure?
Replace
data{1}(1,1) = 212;
by
data{1}(1,1) = {212};
per isakson
per isakson le 10 Juil 2016

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by