How to plot a useful graph with a lot of data

29 views (last 30 days)
I am trying to plot graphs for different variables against crash risk however each variable has nearly 62000 columns down so my graphs are coming out as shown above with no analysis really being able to be done at all. Just wondering if anyone at any tips
  6 Comments
Mario Malic
Mario Malic on 21 Dec 2023
Maybe you should try to analyze your data w.r.t. car brands, years, categories of accidents?
Sam Chak
Sam Chak on 21 Dec 2023
@Danny, the Excel sheet does not contain plottable data values. I think the correct data file is 'Zscore.txt'.
opts = detectImportOptions('Help code and graph.xlsx');
preview('Help code and graph.xlsx',opts)
ans = 8×1 table
fprintf__PlottingData____n__ _______________________________________________________ {'data = load('Zscore.txt');' } {'X = data(:, 1); y = data(:, 2);' } {'m = length(y); % number of training examples' } {0×0 char } {'% Plot Data' } {'% Note: You have to complete the code in plotData.m'} {'plotData(X, y);' } {0×0 char }

Sign in to comment.

Accepted Answer

SAI SRUJAN
SAI SRUJAN on 27 Dec 2023
Hi Danny,
I understand that you are trying to plot graphs for a very large dataset, with each variable having around 62,000 data points.
This is a common challenge when working with large datasets, as traditional plotting methods can become ineffective due to overplotting, where too many data points overlap and make the plot unreadable. In the context of MATLAB, there are several functions and approaches that can help you manage and analyze your large dataset effectively:
Follow the given code snippet to proceed further,
% To sample your dataset,
% you can use the datasample function or simply use indexing to select a subset of your data.
sample_data = datasample(data, 1000, 'Replace', false);
% To decimate your data,
% MATLAB provides the decimate function, which reduces the sample rate of a signal by an integer factor.
decimated_data = decimate(data, factor);
%If you need to resample your data to a new fixed rate, you can use the resample function.
[resampled_data, new_time] = resample(data, original_time, new_rate);
For a comprehensive understanding of the mentioned functions in MATLAB, please refer to the following documentation.
I hope this helps.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!