How to put these values into one array ?

1 visualización (últimos 30 días)
Mohamed Ahmed
Mohamed Ahmed el 16 de Mzo. de 2022
Comentada: Mohamed Ahmed el 16 de Mzo. de 2022
I have this vector X which is equal to
X =
Columns 1 through 8
1 2 3 4 5 6 7 8
I want to convert it into this format
X =
1, 2, 3, 4, 5, 6, 7, 8
How can I achieve this ?
  2 comentarios
KSSV
KSSV el 16 de Mzo. de 2022
Convert where? You want to write it into a text file?
Mohamed Ahmed
Mohamed Ahmed el 16 de Mzo. de 2022
yes using fprintf

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 16 de Mzo. de 2022
x = 1:8 ;
f = [repmat('%d,',1,length(x)-1),'%d\n'] ;
fprintf(f,x)
1,2,3,4,5,6,7,8
  15 comentarios
KSSV
KSSV el 16 de Mzo. de 2022
x = logspace(log10(1),log10(10),10);
f = [repmat('%.4f,',1,length(x)-1),'%.4f'] ;
fprintf(fid,['frequency points = "', f,'";'],x);
Mohamed Ahmed
Mohamed Ahmed el 16 de Mzo. de 2022
yess, this one worked.
Thank you!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by