How to create a function that produces 2 histograms?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a dataset with 2 columns and 9862 rows.
I need to make a figure consisting of two panels where the upper panel is the histogram of one column and the lower panel is the histogram of the other column.
Dd = RiverData(:,1); % daily discharge
Dr = out(); % daily rainfall
function histfunction(Dd,Dr)
% histogram function takes in the daily discharge and rainfall and histograms them
% Dd = Daily discharge, Dr = Daily rainfall
plot(Dr,Dd)
end
So far, I've come up with this (I'm only making one right now but I can't even manage that), but clearly I have made some sort of mistake and I can not figure it out.
0 Kommentare
Antworten (2)
Steven Lord
am 14 Dez. 2022
2 Kommentare
Steven Lord
am 14 Dez. 2022
Most functions in MATLAB include examples on their documentation pages. The tiledlayout documentation page to which I linked above has 14 examples and the histogram documentation page has 10.
Part of the purpose of those examples is to teach users how to use those functions, but another part of their purpose is to serve as starting points. Find examples on those pages that look close to what you want to do, copy them into your code, and modify them so they meet your needs. Once you have them working as a script, create a function file and put that code inside it. You'll need to decide what input and output arguments your function should have, but the documentation describes how to specify those in your function's definition statement.
Cris LaPierre
am 14 Dez. 2022
tiledlayout(2,1);
[X,Y,Z] = peaks(20);
% Tile 1
nexttile
surf(X,Y,Z)
% Tile 2
nexttile
contour(X,Y,Z)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
