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

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.
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
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