フィルターのクリア

need help with fprintf

1 回表示 (過去 30 日間)
Jung
Jung 2019 年 3 月 26 日
コメント済み: Walter Roberson 2019 年 3 月 27 日
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

回答 (1 件)

Walter Roberson
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 件のコメント
Jung
Jung 2019 年 3 月 27 日
Thanks for the reply.
What if instead of fixed value, such as 0.4 in the example, I'd like a range of value for x(1)... so that whenever I calibrate the data, the rate/percentage of differences is constant for x(1) and x(2).
For instance, I would want my parameters to be calibrated within the 10% range so [0.9 to 1.2] so these values would be multiplied by variables
Walter Roberson
Walter Roberson 2019 年 3 月 27 日
Change the 0.4 to a variable name of a variable you calculate just before this.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by