Plot graph between Standard deviation vs Gamma

3 views (last 30 days)
ALOK RAJ
ALOK RAJ on 14 May 2019
Answered: Rahul on 18 Jul 2025
Like I am saving standard deviation in xlsx file, in the same way if i save gamma value in other xlsx file and then I want to plot a graph between standard deviation vs gamma. How can I do that?

Answers (1)

Rahul
Rahul on 18 Jul 2025
Hi Alok,
I understand you are trying to saving standard deviation values in one Excel file and gamma values in another, and would like to plot a graph with standard deviation vs gamma. That’s a very reasonable workflow, and MATLAB makes it easy to load data from Excel files and use it for plotting.
Assuming each '.xlsx' file contains a single column of numeric values, one for standard deviations and one for gamma values you can follow the approach mentioned below:
% Read standard deviation data
stdData = readmatrix(
'std_values.xlsx'); % replace with your actual filename
% Read gamma values
gammaData = readmatrix(
'gamma_values.xlsx'); % replace with your actual filename
% Ensure both vectors are column vectors
stdData = stdData(:);
gammaData = gammaData(:);
% Optional: check if they have the same length
if length(stdData) ~= length(gammaData)
error('Standard deviation and gamma vectors must be the same length.');
end
% Plot
figure;
plot(gammaData, stdData, 'o-', 'LineWidth', 1.5, 'MarkerSize', 6);
xlabel('Gamma');
ylabel('Standard Deviation');
title('Standard Deviation vs Gamma');
grid on;
The 'readmatrix' function loads numeric data from the Excel files. If the input data includes headers or more structure, we can switch to 'readtable' and extract specific columns. The ':' operation ensures both variables are column vectors for consistent plotting, whereas the 'plot' function creates a clean line chart of standard deviation vs gamma.
You can customize the markers, line style, and axis labels as needed. In case you want to generate these values in a loop and write them to Excel, you could also consider storing them in a single file with two columns '([gamma, std])' to simplify the workflow.
For more information regarding the usage of 'plot' function used in the given code snippet, you can refer to the following documentation link:

Community Treasure Hunt

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

Start Hunting!