Is it possible to assign variables to a script?
Mostrar comentarios más antiguos
I am running a script that uses the same notation for the equations, but one script is for the month of January and the other is for the month of May. Is there a way to keep the variables seperate if i was to run the scripts together to compare one against the other?
7 comentarios
Walter Roberson
el 2 de Ag. de 2019
... Make it into a function that you pass the data (or name of data file) into.
rammah nagi
el 2 de Ag. de 2019
dpb
el 2 de Ag. de 2019
doc function
rammah nagi
el 3 de Ag. de 2019
Editada: rammah nagi
el 3 de Ag. de 2019
dpb
el 3 de Ag. de 2019
"doc function" was hint to read the documentation for the function keyword to learn the essence of writing functions...
You either write a function that calls the calculation with the necessary input to identify the case being operated on and return the result in different variables or as cell array or in this case it could be a 2D array since both are same length...that's your choice in how you wish to write it.
Or, you plot the first case, then use
hold on
and add the second...
Since we "know nuthink!" about what this function is, it's not possible to say much about actual specific code.
rammah nagi
el 3 de Ag. de 2019
Walter Roberson
el 3 de Ag. de 2019
Editada: Walter Roberson
el 4 de Ag. de 2019
function [hour, Pout] = MyFunction(month)
... Appropriate code that assigns to hour and Pout
Then
[h1, p1] = MyFunction('Jan');
[h2, p2] = MyFunction('May');
plot(h1, p1, h2, p2)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!