フィルターのクリア

Can anyone please check this "for" loop for me?

2 ビュー (過去 30 日間)
Ismail Qeshta
Ismail Qeshta 2017 年 10 月 16 日
コメント済み: OCDER 2017 年 10 月 17 日
Hi,
I would like to obtain the vector output of the following "for" loop:
close all; clear all;
C1=[1.25 1.36];
b=[10];
for i=1:2;
for j=1:2;
Formula=C1/(sqrt(b));
line1 = ['set C1 ' num2str(C1(i)) ';'];
fid=fopen('file.txt','w');
fprintf(fid,'%s\n',line1);
end
end
I would like to obtain the output from the Formula in the form of vector values [ ] printed in a file.
Thank you very much.
Regards, Ismail
  2 件のコメント
Christoph F.
Christoph F. 2017 年 10 月 16 日
編集済み: Christoph F. 2017 年 10 月 16 日
Your code repeatedly opens file.txt and never closes it.
I suggest opening file.txt once, outside the loop, and closing it after the loops are finished.
Ismail Qeshta
Ismail Qeshta 2017 年 10 月 16 日
Hi Christoph. Thanks for your suggestion. Can you please show me this in an example?

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

採用された回答

OCDER
OCDER 2017 年 10 月 16 日
clear
clc
close all
C1 = [1.25 1.36];
b = 10;
Formula = C1/(sqrt(b));
fid=fopen('file.txt', 'w');
fprintf(fid,'set C1 %f;\n', C1);
fclose(fid);
  2 件のコメント
Ismail Qeshta
Ismail Qeshta 2017 年 10 月 17 日
Thank you very much Donald.
OCDER
OCDER 2017 年 10 月 17 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by