Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

I have a txt file and i read the txt file in matlab . After reading the text file i need to change a value in some line . But the value isnt first word or number in the line. The number is to be replacd with a output value from simulink simulation.

2 Ansichten (letzte 30 Tage)
clc;
fid = fopen('summary.txt'); n = 1; textline = {}; while( ~feof(fid) ) textline(n,1) = {fgetl(fid)};
if ( n == 28 ) temp = char(textline(n));
s1 = textscan(temp ,'%s %s %s %s %d %s %s %s %s %s %s %s '); % This code reads the 28 line where want makes the changes
s2= s1(1,5); %This is the i want wanna change
s3=Omega_speed.signals.values(1); % The Output from a Simulation stored in a simout variable
textline(n,1) = {['Starting Rotary Speed = %d ',t,' 1/min (Clockwise Rotation) at Mass 7 ',temp(regexp(temp , '\s ', 'once'):end)]};
end
n = n + 1;
end
fclose(fid)
fid = fopen('summary_1.txt', 'w') % this file is created with the new data created.
for(n = 1:length(textline))
fwrite(fid, cell2mat(textline(n)));
end
fclose(fid)

Antworten (0)

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by