for loop, write to text file, append, fprintf, pass input parameters

Im looking to pass input parameters (Youngs Modulus) to a text file fprintf(fileID,'<E>%f<E/>\n',E_out);
The text file is running FEBio in terminal where im wanting it to run each of the individual values for E and present me with 3 different set of results.
Am i right in doing something like the following:
E_out = [100000 200000 30000]
for i = 1:length(E)
fprintf(fileID,'<E>%f<E/>\n',E_out(i));
end
And how would i get this to to then pass to my main file containg the FEBio textfile code.

5 件のコメント

Guillaume
Guillaume 2020 年 1 月 29 日
Am i right in doing something like the following:
If you fix the for bound to be length(E_out) instead of length(E), yes. Personally, I'd use numel rather than length. Note that you don't even need a loop,
E_out = [100000 200000 30000];
fprintf(fileID,'<E>%f<E/>\n',E_out);
would produce the same result. Whether %f is the right format is up to you. %g in this case would work better.
And how would i get this to to then pass to my main file containg the FEBio textfile code.
This part of your question is really not clear.
Lewis Doherty
Lewis Doherty 2020 年 1 月 29 日
Ok tahn ks for the info. As for the second question...
So if i had say a parameters.m file with the above code (varying Young modulus and permeability values) and then a main.m file with the FEBio text file code. I take it the parameters.m file with the changing E and k values would have to call upon the main.m file to changhe the value of E in the FEBio code? If that makes sense
Lewis Doherty
Lewis Doherty 2020 年 1 月 30 日
Sadly this still wouldnt work for me
Mohammad Sami
Mohammad Sami 2020 年 1 月 30 日
It's not clear to me what FEBio text file code. Is it something outside Matlab ?
Lewis Doherty
Lewis Doherty 2020 年 1 月 30 日
Yes. A finite element solver.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

質問済み:

2020 年 1 月 29 日

コメント済み:

2020 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by