Effacer les filtres
Effacer les filtres

How do i write a text..

2 vues (au cours des 30 derniers jours)
George
George le 8 Juin 2013
I wrote this code and i would like to write a text on the top of this file and on the bottom. How can i do this?
grayImage = imread('moon.tif');
[height, width] = size(grayImage)
[X, Y] = meshgrid(1:width, 1:height);
numberOfPixels = length(X(:))
points = [X(:) Y(:) grayImage(:)];
A = [X(:) Y(:) grayimage(:)];
fid = fopen('moon.txt','wt');
for ii = 1:size(A,1)
fprintf(fid,'%g\t',A(ii,:));
fprintf(fid,'\n');
end
fclose(fid)

Réponse acceptée

Image Analyst
Image Analyst le 8 Juin 2013
Modifié(e) : Image Analyst le 8 Juin 2013
Simply add a fprintf() before and after you write the gray levels to the text values.
fid = fopen('moon.txt','wt');
fprintf(fid,'Stuff at the beginning of the file.\n');
for ii = 1:size(A,1)
fprintf(fid,'%g\t',A(ii,:));
fprintf(fid,'\n');
end
fprintf(fid,'Stuff at the end of the file.\n');
fclose(fid)
  5 commentaires
Image Analyst
Image Analyst le 8 Juin 2013
Sorry - forgot to add that you need to pass in the file ID. See corrected code. If you don't have that it just prints to the command window.
George
George le 8 Juin 2013
thank you for your time!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Text Analytics Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by