how can i solve this error appears when I try reading position

조회 수: 1 (최근 30일)
Unai Bilbao
Unai Bilbao 2021년 4월 5일
답변: Vinod 2021년 4월 5일
Hello:
I am trying to read the position (latitude and longitde) from a data with thingSpeakRead and the next error appears:
Dot indexing is not supported for variables of this type
This is my code from MATLAB Visualizations code:
data = thingSpeakRead(1299642, 'location',true)
lon = data.Longitude;
lat = data.Latitude;
figuregeoplot(lat,lon,'red-*')
geobasemap("topographic")
title("Ground Truth Trajectory")
And this is the output:
data =
[]
Dot indexing is not supported for variables of this type.
Error in Posicion (line 3)lon = data.Longitude;
Someone knows what is happening?
Thank you
  댓글 수: 1
KSSV
KSSV 2021년 4월 5일
Just run this line:
data = thingSpeakRead(1299642, 'location',true)
There is no data, it is empty. As the data is empty you are getting error from the next line data.. Check this line alone why the data is empty.

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

답변 (1개)

Vinod
Vinod 2021년 4월 5일
Your channel is empty, and you are trying to index into an empty array retrieved from the channel. Try this:
data = thingSpeakRead(1299642, 'location',true)
if ~isempty(data)
lon = data.Longitude;
lat = data.Latitude;
figuregeoplot(lat,lon,'red-*')
geobasemap("topographic")
title("Ground Truth Trajectory")
end

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Read Data from Channel에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by