Borrar filtros
Borrar filtros

Run one line or the other Option

1 visualización (últimos 30 días)
Zeeshan Abbas
Zeeshan Abbas el 19 de Jul. de 2019
Comentada: Zeeshan Abbas el 19 de Jul. de 2019
I have a code in which I need two options. Either user wants to give message at runtime or want to read from a file.
message = fileread('message.txt');
%OR
message = input('Enter your message to embedd: ', 's');
How can I get prompt message in Matlab, either to select a file or enter your message?

Respuesta aceptada

madhan ravi
madhan ravi el 19 de Jul. de 2019
Certainy not sure what you want to do but see if https://in.mathworks.com/help/matlab/ref/msgbox.html does what you want.
  3 comentarios
madhan ravi
madhan ravi el 19 de Jul. de 2019
According to what I understand:
Inp = input('Press 1 or 0');
if ~Inp % if Inp is 0
message = fileread('sample.txt');
else
message = input('Enter your message to embedd: ', 's');
end
Zeeshan Abbas
Zeeshan Abbas el 19 de Jul. de 2019
Exactly what I needed. Fantastic!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by