How to access much data from excel sheet to matlab?
7 views (last 30 days)
Show older comments
fileName = 'try.xlsx'; a = xlsread(fileName); x = a(:,1); y = a(:,60); plot(x,y)
I am getting error as: Attempted to access a(:,60); index out of bounds because size(a)=[59,8].
0 Comments
Answers (1)
Prateekshya
on 21 Aug 2024
Hello Manish,
The error indicates that there are 59 rows and 8 columns in the excel file however, you are trying to access 60th column. For getting rid of this error, please make sure you are accessing elements within the available range that is a(1,1) to a(59,8).
Here is an example to do the same:
% Read data from the Excel file
fileName = 'try.xlsx';
a = xlsread(fileName);
% Check the size of 'a' to understand its dimensions
disp(size(a)); % This will display the number of rows and columns
% Correct the column indices based on the actual data
x = a(:, 1); % Assuming the first column is correct
y = a(:, 8); % Adjust this to the correct column index, e.g., 8 instead of 60
% Plot the data
plot(x, y);
xlabel('Column 1');
ylabel('Column 8'); % Adjust the label according to the actual data
title('Plot of x vs. y');
I hope this helps!
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!