Hello,
I'm trying to create a topographic map, I keep getting a message in the comand window that says. Index exceeds the number of array elements. I needs some help making a topographic map for my class.
clf
disp('CTD_lat_lon.csv') % Display the file
table1 = readtable('CTD_lat_lon.csv') % creates a table from the data from the first OMG file
latitude = table2array(table1(:,2));
longitude = table2array(table1(:,3));
geoplot('latitude','longitude','-*')
geolimits([63.5 64],[-42 -40])
geobasemap topographic

댓글 수: 4

Voss
Voss 2022년 4월 18일
Can you upload the file CTD_lat_lon.csv (using the button with the paperclip icon)?
its already in there, uner current folders.
the cyclist
the cyclist 2022년 4월 18일
편집: the cyclist 2022년 4월 18일
@_ meant could you upload the file here, for us to use for debugging your code. You can use the paperclip icon in the INSERT section of the toolbar. Also, it would be helpful for you to report the complete error message, and what line of code causes it.
The line of code that causes the error starts with
geoplot('latitude','longitude','-*')
Here are the error messages.
Error using geoplot (line 71)
Expected lat to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
I also get another error message for this section
table1 = readtable('CTD_lat_lon.csv')
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.

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

답변 (1개)

the cyclist
the cyclist 2022년 4월 18일
There are a couple issues with your code. First, MATLAB's algorithm to automatically detect the file delimiter seems to have gotten confused, so I set the explicitly. Also, the input file had some spurious whitespace characters that I got rid of.
More importantly, your enclosed the input arguments in quotes, which MATLAB just interprets as the string 'latitude' instead of the variable latitude. I fixed that up, too.
table1 = readtable('CTD_lat_lon.csv','delimiter',','); % creates a table from the data from the first OMG file
latitude = table2array(table1(:,2));
longitude = table2array(table1(:,3));
geoplot(latitude,longitude,'-*')
geolimits([63.5 64],[-42 -40])
geobasemap topographic

댓글 수: 1

I really appreciate the advice, thank you. I' new to matlab so I make alot of easy mistakes still. Thank you! Thank you!

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2022년 4월 18일

댓글:

2022년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by