How to make the x and y axis labels and the title an input argument for a function

조회 수: 1 (최근 30일)
So here is the code that I have to keep for my class assignment. I am trying to figure out how to make it that the title and the axis labels are an input by the user and not hard coded.
function filePlot(filename,graphTitle,xAxisLabel,yAxisLabel)
raw_data=load(filename);
% Assign the first column of data in raw_data to x, and the 2nd to y.
% Create a scatter plot of the fish counts vs. the gas concentration.
% Add appropriate graph title and axis labels.
% For both x and y, display the mean and standard deviation in the command window.
endfunction
I have everything else and it works fine except for there is no title or axis labels. Here is the code that I have so far.
fish=raw_data(:,1);
dissolved_gas=raw_data(:,2);
scatter(fish,dissolved_gas,'*:b')
M = mean(fish)
M = mean(dissolved_gas)
S = std(fish)
S = std(dissolved_gas)

답변 (1개)

Walter Roberson
Walter Roberson 2022년 4월 17일
title(graphTitle) ;
xlabel(xAxisLabel);
ylabel(yAxisLabel);

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by