- Call xlsread multiple times to read each column.
- Change the range (or stop specifying a range) to read the entire table or more columns at once.
how to polar plot excel data in 2D?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone, I was tasked to plot a 2-D polar plot of an antenna gain using data sheets from excel. However by executing the code, I received the error "Index in position 2 exceeds array bounds. Index must not exceed 1." I was supposed to use data from box H2 to H26 for this segment of the excel sheet.
I'm not the best coder, but here is my code. Please help me if possible
clc;
clear all;
M = xlsread('AntennaA.xlsx', 'H2:H26');
patternCustom(M(:,3),M(:,2),M(:'1),'CoordinateSystem','rectangular','Slice','theta','SliceValue',M);
title('2D Antenna A Phi Bandwidth')
0 commentaires
Réponses (1)
Benjamin Kraus
le 8 Mar 2023
Your current code:
M = xlsread('AntennaA.xlsx', 'H2:H26');
Is only returning a single column of your matrix (column "H").
The resulting matrix is 26 rows and 1 column.
You are then indexing into the matrix like this:
M(:,3),M(:,2),M(:1)
That asks for the third, second, and then first columns of the matrix, but there is only one column.
The error you are getting is telling you that your index ("3" and "2") is larger than the size of the matrix ("1").
I assume you also need to read at least two other columns, so you have three columns to plot.
Some options:
tbl = readtable('AntennaA.xlsx');
M = table2array(tbl(:,2:end));
el = 0:15:180;
patternCustom(M, 90-el, tbl.Azimuth);
2 commentaires
Benjamin Kraus
le 8 Mar 2023
The data in tbl includes both the columns A (labeled Azimuth) and H (labeled Elevation90deg).
plot(tbl.Azimuth, tbl.Elevation90deg)
If you have a recent version of MATLAB (R2022a and newer) you can also plot directly from the table:
plot(tbl,'Azimuth', 'Elevation90deg')
Voir également
Catégories
En savoir plus sur Calendar dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!