Borrar filtros
Borrar filtros

Text and Number in a Matrix/row

4 visualizaciones (últimos 30 días)
Dhirendu Somani
Dhirendu Somani el 26 de En. de 2021
Comentada: Dhirendu Somani el 30 de En. de 2021
I want to create a row which include both numbers and text.
Sample Code
%%%% Input %%%%%%%
Text : {'x1=','y1=','z1='}
Nos : [1:1:3];
% Sample Code
for i=1:length(Nos)
Row(1,i) = Text(i);
Row(1,i+1) = Nos(i);
end
% Need Output as below
Row = [ x1=1 y1=2 z1=3 ]; % (numbers and text in alternate columns )
% Attached image for needed output
  5 comentarios
Dhirendu Somani
Dhirendu Somani el 28 de En. de 2021
@Mathieu NOE Yes my goal is to store in 6 columns like a excel file
Mathieu NOE
Mathieu NOE el 28 de En. de 2021
hello
would it be just one line as the format you showed or dou you intend to have column oriented vectors for x1, y1, z1 ?
if yes maybe you should put those three labels as header line in the first row and then store the vectors below (my 2 cents)

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de En. de 2021
Text = {'x1=','y1=','z1='}
Text = 1x3 cell array
{'x1='} {'y1='} {'z1='}
Nos = [1:1:3]
Nos = 1×3
1 2 3
Noscell = num2cell(Nos)
Noscell = 1x3 cell array
{[1]} {[2]} {[3]}
Output = reshape([Text(:).'; Noscell(:).'], 1, [])
Output = 1x6 cell array
{'x1='} {[1]} {'y1='} {[2]} {'z1='} {[3]}

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by