Creating a function that returns multiple graphs
26 views (last 30 days)
I would like to create a function that returns as output arguments two different histograms such that in the script file either of the two graphs can be called. If I am not mistaken, I could do this for one histogram as follows:
How do I adjust the code for two histograms?
TADA on 27 Dec 2018
function [h1,h2] = myplot(data, nbins)
h1 = histogram(data,nbins);
h2 = histogram(data,nbins);
function h = myplot(data, nbins)
h(1) = histogram(data,nbins );
h(2) = histogram(data,nbins);
You Will Have To Decide How You Want To Send The Data To This Function. If In Matrices Or Cell Arrays Or Multiple Arguments (worst Option Probably), but This Above Is The General Idea.
The Second Option Is Somewhat More Versatile As You Can End Data An Array And Run In A Loop Generating As Many Histograms As You Need And Return All Of Them In A Vector Of Histogram Handles.