How to plot a useful graph with a lot of data

조회 수: 29 (최근 30일)
Danny
Danny 2023년 12월 20일
답변: SAI SRUJAN 2023년 12월 27일
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
Mario Malic
Mario Malic 2023년 12월 21일
Maybe you should try to analyze your data w.r.t. car brands, years, categories of accidents?
Sam Chak
Sam Chak 2023년 12월 21일
@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 }

댓글을 달려면 로그인하십시오.

채택된 답변

SAI SRUJAN
SAI SRUJAN 2023년 12월 27일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resampling Techniques에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by