Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

function which calls M-File and set their variables

1 Ansicht (letzte 30 Tage)
Ajira
Ajira am 18 Dez. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hi guys,
Is it possible to write a function which first take 1 input from user and based on that open one of two M-Files and after that ask user again now to enter the variables in that already called M-File??
thx,
  1 Kommentar
Guillaume
Guillaume am 18 Dez. 2019
It may be just a matter of semantic but opening an m file is typically done in order to edit the file. On the other hand, code typically run m file, which is a different operation.
It is trivial to decide which m code to run based on user input.
It's not very clear what you want to do with the second part of your question. If you're asking that the code then change actual values that are hardcoded in the m file, then you need to rethink your design and use functions with inputs.

Antworten (1)

Adam Danz
Adam Danz am 18 Dez. 2019
Bearbeitet: Adam Danz am 19 Dez. 2019
"Is it possible to write a function which first take 1 input from user and based on that open one of two M-Files ..."
Yes. There are lots of ways to get input from a user. If you're asking the user to open a file, you could used
function output = myFunction(input)
[file,path] = uigetfile(filter, title); % See link above
end
"... and after that ask user again now to enter the variables in that already called M-File?"
Here are ways to get that input from the user
lots more....
If you get stuck, share your updated code and describe what's wrong; I'd be glad to help out.

Community Treasure Hunt

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

Start Hunting!

Translated by