Convert string to 256 Characters
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
How to create the Matlab source text which will be equivalent to this Fortran text? The character variable must be 256 characterts long
Character*256 TEXT
TEXT = 'Unformatted Data Version='
Print*, TEXT
END
Thanks!
0 comentarios
Respuestas (2)
  Walter Roberson
      
      
 el 27 de Sept. de 2024
        
      Editada: Walter Roberson
      
      
 el 27 de Sept. de 2024
  
      TEXT = sprintf('%256s', 'Unformatted Data Version=');
fprintf(FILEID, "%s\n", TEXT)
0 comentarios
  Ronit
      
 el 27 de Sept. de 2024
        
      Editada: Ronit
      
 el 27 de Sept. de 2024
  
      In MATLAB, you can convert a string to a fixed length by padding it with spaces or truncating it to ensure it is exactly 256 characters long by using the "pad" function.
text = 'Unformatted Data Version=';
textUpdated = pad(text, 256);
disp(textUpdated);
Here is the documentation link for "pad" function: 
I hope it helps your query!
0 comentarios
Ver también
Categorías
				Más información sobre Characters and Strings en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


