フィルターのクリア

How to document the input from Matlab into the file

1 回表示 (過去 30 日間)
Anh Mai
Anh Mai 2021 年 8 月 17 日
コメント済み: Anh Mai 2021 年 8 月 21 日
Hi all,
I have a code that allow user to enter multiple inputs via 'For' loop. However, I usually don't remember the inputs unless I have to note them down before running the MATLAB. Hence, I am wonder if there is a way to output or save all the inputs that I entered into a file right after MATLAB run. Below is the example of my inputs with for loop. Thank you guys. Much appreciate.
count=input('Enter numbers of item:');
for k=1:count
%%%Below here are the inputs for every loop, count
fprintf('Please enter BMP number %0.0f information, start with the deepest one \n',k);
shape=input('1 = rectangular,2 = circle,3 = ellipse,4 = polygon: ');
nlayers=input('Enter number of layers for this BMP: ');
ind=input('Set type of BMPs, 2=pervious pave, 3=bioretention, 4=grass swales: ');
if shape==1 %Rectangular
%%%code 1
elseif shape==2 %Circle
%%%code 2
elseif shape==3 %Ellipse
%%%code 3
else disp('This is polygon (triangle, rhomnus, hexagon, etc)')
%%%code 4
end
end
  1 件のコメント
Rik
Rik 2021 年 8 月 17 日
How about fprintf?

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

採用された回答

Jan
Jan 2021 年 8 月 19 日
編集済み: Jan 2021 年 8 月 19 日
Using input in the command window is useful for short hacks only. For real applications either use a GUI and store the inputs by writing files (see: doc fprintf). Or create the files in an editor and import them (see: readmatrix, fscanf, etc).
Alternatively create a script or function, which defines the inputs and call the function directly. Using Matlab's editor is more comfortable than the command window, because the results are reproducible. A typo inside the input using input() will be very confusing and hard to find.
  1 件のコメント
Anh Mai
Anh Mai 2021 年 8 月 21 日
Thanks alot Jan, it works

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by