The attached file has been written using fprintf. By the way, why does the text appear aligned when it's opened with notepad and not aligned when opened with matlab?
The function used to write the text file is the following:
function [] = IPC2(namefile, d, epcheck)%This Function registers input data to a text file for further use.
global ha hp i omega OMEGA teta0if epcheck == 3 psp = evalin('base', 'psp');else psp = ' ';endalphadate = evalin('base', 'alphadate');fID = fopen([namefile,'.txt'],'w');fprintf(fID,'%s \r\n', 'UNINA SPACE MAST Input File');fprintf(fID,'%s %i', 'Input Type Identifier:', 1); fprintf(fID,'\r\n \r\n');header = strings(9);v = nan(8);u = strings(6);header(1) = 'ha:'; header(2) = 'hp:'; header(3) = 'i:'; header(4) = 'omega:'; header(5) = 'OMEGA:'; header(6) = 'teta0:'; header(7) = 'Date & time:';header(8) = 'alphadate:';header(9) = 'Satellite''s entry point:';v(1) = ha/1000;v(2) = hp/1000;v(3) = i*180/pi;v(4) = omega*180/pi;v(5) = OMEGA*180/pi;v(6) = teta0;v(7) = psp;v(8) = alphadate*180/pi;u(1) = 'km';u(2) = 'km';u(3) = '°';u(4) = u(3);u(5) = u(3);u(6) = u(3);u(7) = '%';u(8) = u(3);for ii = 1 : 6 fprintf(fID, '%s \t\t', header(ii)); fprintf(fID, '%f ', v(ii)); fprintf(fID, '%s\r\n', u(ii));endfprintf(fID, '\r\n');fprintf(fID, '%s\r\n', 'GROUND TRACK INPUT');fprintf(fID, '%s \t\t\t\t', header(7)); fprintf(fID, '%s \r\n', d);fprintf(fID, '%s \t\t\t\t', header(8)); fprintf(fID, '%s', num2str(alphadate*180/pi));fprintf(fID, '%s\r\n', u(8));if epcheck == 1 ep = 'Ascending node';endif epcheck == 2 ep = 'Descending node';endif epcheck == 3 psp = num2str(psp); ep = psp;endfprintf(fID, '%s \t\t', header(9)); fprintf(fID, '%s', ep);if epcheck == 3 fprintf(fID, '%s', u(7));endend
In this case, epcheck == 3.
I need to get all the numbers in the text file and the datetime string
Best Answer