need help with fprintf
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have this line of script where it takes a parameter text file (par.txt) and changes the variables for calibration purpose.
fout=fopen('par.txt','w+')
fprintf(fout,'wcwp\t%6f\t%6f\t%6f\t%6f\t%6f\r\n', x(1),x(1),x(1),x(1),x(2));
Here, I'd like to implement this line so I can increase the values at a same rate as the other varialbes
fprintf(fout,'wcwp\t0.4*%6f\t0.4*%6f\t0.4*%6f\t0.4*%6f\t0.4*%6f\r\n', 0.4,0.4,0.4,0.4,0.8);
But, once I run this script, my output looks like this;
wcwp 0.4*0.400000 0.4*0.400000 0.4*0.400000 0.4*0.400000 0.4*0.800000
I need to find a way where I can have %6f value multiply by something and still show the final answer to the txt file
Any help would be appreciated
0 个评论
回答(1 个)
Walter Roberson
2019-3-26
fprintf(fout,'wcwp\t%6f\t%6f\t%6f\t%6f\t%6f\r\n', 0.4*([x(1),x(1),x(1),x(1),x(2)]);
2 个评论
Walter Roberson
2019-3-27
Change the 0.4 to a variable name of a variable you calculate just before this.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!