how to write Text file usiNG MATLAB
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
R-0
{
position (0.2 1.48 0.01);
pRef 2.0e-5;
fftFreq 1024;
}
I want to write a matlab script to produce a text file having a repated lines like the above line while changing the values inside
R-i
{
position (x(i) y(i) 0.01);
pRef 2.0e-5;
fftFreq 1024;
}
where, i, x(i) and y(i) are imported from x file
clc;
clear;
Excel= xlsread('receiverlocations.xlsx','points') ;
x= Excel(:,1)';%x
y= Excel(:,2)';%y
fid = fopen('ny.txt','wt');
for i=1:length(x)
i=i;
fprintf(fid, '{\n');
fprintf(fid, 'R-');
fprintf(fid,'i');
fprintf(fid, '\n');
fprintf(fid,'position','%6s %12s','x(i)','%6s %12s\n','y(i)');
fprintf(fid, '\n');
fprintf(fid, '}\n');
fprintf(fid, '\n');
end
fclose(fid)
I have tried the previous lines but variable like i is printed as i not the corresponding value
can anyone help?
0 comentarios
Respuesta aceptada
Rik
el 11 de Ag. de 2020
You forgot to put in the arguments as data:
clc;
clear;
Excel= xlsread('receiverlocations.xlsx','points') ;
x= Excel(:,1)';%x
y= Excel(:,2)';%y
fid = fopen('ny.txt','wt');
for i=1:length(x)
pRef=___
fftFreq=____
fprintf(fid, [...%split on multiple lines for readability, use 1 statement for speed
'R-%d\n',...
'{\n',...
' position %.2f %.2f\n',...
' pRef %e\n',...
' fftFreq %d\n',...
'}\n',...
'\n'],...
i,x(i),y(i),pRef,fftFreq);
end
fclose(fid)
Más respuestas (0)
Ver también
Categorías
Más información sobre JSON Format 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!