How to Plot Variable Functions With a Matrix in MATLAB
MATLAB is a professional programming package that contains a range of prebuilt functions for importing, analyzing, modeling and graphing technical data. Commonly, parameters for a mathematical function will need to be systematically varied during your analysis. The MATLAB plotting commands allow multiple curves to be plotted simultaneously by formatting multiple curves in a matrix.
Instructions
-
-
1
Define a one-dimensional signal by importing your own data or creating a vector of random noise:
my_signal = rand(1,100);
-
2
Define a one-dimensional vector of variable magnitudes or whichever factor you wish to vary in your signal:
my_factors = [1 3 5 10];
-
-
3
Multiply the transpose of your signal vector by your factor vector to create a matrix containing a version of your signal for each factor multiplier:
my_matrix = my_signal' * my_factors;
-
4
Plot the resultant curves using the "plot()" function. Curves equal to the number of factors will be overlaid in different colors.
plot(my_matrix)
-
1
References
- Photo Credit BananaStock/BananaStock/Getty Images