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 comentarios

Tariq Hammoudeh
Tariq Hammoudeh el 5 de Dic. de 2021
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 el 5 de Dic. de 2021
Hint to OP: Always read the "See Also" section of the documentation
Tariq Hammoudeh
Tariq Hammoudeh el 5 de Dic. de 2021
Editada: Walter Roberson el 5 de Dic. de 2021
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);

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 5 de Dic. de 2021

Comentada:

el 5 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by