getting a number from a text file

I have txt file with 1 number inside only, nothing else.
is there a way to get that number as a variable so that i can use an if statement on it, more specifically if an inputted number is greater than the number in the txt file.

7 件のコメント

dpb
dpb 2021 年 12 月 5 日
Tariq Hammoudeh
Tariq Hammoudeh 2021 年 12 月 5 日
Ok thank you, reading it as a matrix worked. But now is there a way for me to have the code change the number in that file after an action.
Jan
Jan 2021 年 12 月 5 日
dpb
dpb 2021 年 12 月 5 日
Hint to OP: Always read the "See Also" section of the documentation
Tariq Hammoudeh
Tariq Hammoudeh 2021 年 12 月 5 日
編集済み: Walter Roberson 2021 年 12 月 5 日
I did read this, but what i need to do is edit the number i have in the text file, so what i did is:
C
R=readmatrix('CashReserve.txt');
"CashReserve" is the name of the txt file.
And what i need to do is be able to update this txt file (CR) after an action.
so is there a way to do that in code
Star Strider
Star Strider 2021 年 12 月 5 日
Walter Roberson
Walter Roberson 2021 年 12 月 5 日
filename = 'CashReserve.txt');
R = readmatrix(filename);
R = R - 1234.56;
writematrix(R, filename);

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

回答 (0 件)

製品

リリース

R2020a

タグ

質問済み:

2021 年 12 月 5 日

コメント済み:

2021 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by