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

1 visualización (últimos 30 días)
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)

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de Abr. de 2022
title(graphTitle) ;
xlabel(xAxisLabel);
ylabel(yAxisLabel);

Categorías

Más información sobre Grid Lines, Tick Values, and Labels en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by