Is it possible to assign variables to a script?
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 2 Août 2019
... Make it into a function that you pass the data (or name of data file) into.
rammah nagi
le 2 Août 2019
dpb
le 2 Août 2019
doc function
rammah nagi
le 3 Août 2019
Modifié(e) : rammah nagi
le 3 Août 2019
dpb
le 3 Août 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
le 3 Août 2019
Walter Roberson
le 3 Août 2019
Modifié(e) : Walter Roberson
le 4 Août 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)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!