Error "Index exceeds matrix dimensions" | MATLAB | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Error "Index exceeds matrix dimensions"
Avatar
paul
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
1
September 19, 2016 - 3:04 pm
sp_Permalink sp_Print

Hello, I am getting error "Index exceeds matrix dimensions" after running this peace of code in matlab analysis. 

readChannelID = 106292;
pumpFieldId = 5;
readAPIKey = 'myApiKey';
timeRange = 10;
[pump, timeStamp] = thingSpeakRead(readChannelID, 'Fields', pumpFieldId, 'numMinutes', timeRange, 'ReadKey', readAPIKey);

I can successfully read other channel's fields, except field5. This was working until September 15th. I have tried clear channel, but still it doesn't work. I have no idea what could be wrongConfused.

Avatar
Adarsh_Murthy

Forum Posts: 59
sp_UserOfflineSmall Offline
2
September 19, 2016 - 4:21 pm
sp_Permalink sp_Print

Hi Paul, 

I couldn't reproduce the error on my end since channel 106292 is a private channel. I replaced the channel ID with 12397, and the following code worked:

readChannelID = 12397;
pumpFieldId = 5;
timeRange = 10;
[pump, timeStamp] = thingSpeakRead(readChannelID, 'Fields', pumpFieldId, 'numMinutes', timeRange);

Could you share the last 10 minutes worth of data in your channel (in json format) using the GET Feed endpoint (https://www.mathworks.com/help/thingspeak/get-a-channel-feed.html)?

Avatar
paul
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
September 19, 2016 - 4:44 pm
sp_Permalink sp_Print
Here you go 

{"channel":{"id":106292,"name":"Solar heating","latitude":"0.0","longitude":"0.0","field1":"collector","field2":"boiler_mid","field3":"boiler_bottom","field5":"pump_state","created_at":"2016-04-06T14:50:48+03:00","updated_at":"2016-09-19T23:35:10+03:00","last_entry_id":52},"feeds":[{"created_at":"2016-09-19T22:57:09+03:00","entry_id":33,"field1":"9.31","field2":"52.44","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T22:59:07+03:00","entry_id":34,"field1":"9.31","field2":"52.31","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T23:01:11+03:00","entry_id":35,"field1":"9.25","field2":"52.31","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T23:03:10+03:00","entry_id":36,"field1":"9.25","field2":"52.25","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T23:05:08+03:00","entry_id":37,"field1":"9.25","field2":"52.13","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T23:07:06+03:00","entry_id":38,"field1":"9.19","field2":"52.13","field3":"21.88","field5":"0"},{"created_at":"2016-09-19T23:09:10+03:00","entry_id":39,"field1":"9.13","field2":"52.13","field3":"21.81","field5":"0"},{"created_at":"2016-09-19T23:11:08+03:00","entry_id":40,"field1":"9.13","field2":"52.00","field3":"21.75","field5":"0"},{"created_at":"2016-09-19T23:13:06+03:00","entry_id":41,"field1":"9.13","field2":"52.44","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:15:11+03:00","entry_id":42,"field1":"9.06","field2":"52.88","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:17:09+03:00","entry_id":43,"field1":"9.06","field2":"53.00","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:19:07+03:00","entry_id":44,"field1":"9.00","field2":"53.00","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:21:11+03:00","entry_id":45,"field1":"9.00","field2":"52.88","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:23:09+03:00","entry_id":46,"field1":"9.00","field2":"52.75","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:25:07+03:00","entry_id":47,"field1":"8.94","field2":"52.69","field3":"21.63","field5":"0"},{"created_at":"2016-09-19T23:27:12+03:00","entry_id":48,"field1":"9.00","field2":"52.56","field3":"21.69","field5":"0"},{"created_at":"2016-09-19T23:29:09+03:00","entry_id":49,"field1":"8.94","field2":"52.50","field3":"21.69","field5":"0"},{"created_at":"2016-09-19T23:31:08+03:00","entry_id":50,"field1":"8.88","field2":"52.44","field3":"21.69","field5":"0"},{"created_at":"2016-09-19T23:33:05+03:00","entry_id":51,"field1":"8.94","field2":"52.38","field3":"21.69","field5":"0"},{"created_at":"2016-09-19T23:35:10+03:00","entry_id":52,"field1":"8.94","field2":"52.25","field3":"21.69","field5":"0"}]}

I am afraid that it is channel specific problem.
Avatar
Adarsh_Murthy

Forum Posts: 59
sp_UserOfflineSmall Offline
4
September 20, 2016 - 8:40 am
sp_Permalink sp_Print

Thanks for sharing the data. I am able to reproduce the error.

While we are working on fixing thingSpeakRead, here are two options that you could consider:

Option 1:

- Enable Field 4: In the channel settings tab of Channel 106292, enable Field 4 by selecting the check box. This should resolve the error. Note that you don't need to add Field 4 Chart to your Channel view page. To disable the Field 4 chart, click on the 'x'. You can add it back later by using the 'Add Visualizations' button.

 

Option 2:

- Edit the thingSpeakRead call: Instead of option 1, you could change the MATLAB code to:

[data, timeStamp] = thingSpeakRead(readChannelID, 'numMinutes', timeRange, 'ReadKey', readAPIKey);

pump = data(:, 4);

 

Let me know if this doesn't fix the error for you. We will post again when thingSpeakRead() is updated.

 

Thanks,

Adarsh

Avatar
paul
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
5
September 20, 2016 - 1:12 pm
sp_Permalink sp_Print

I used option 2 and it works now. Thanks for helpSmile

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: jacktheripper125
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

Nsneilotof

angieus2

goldiepw11

BinanceoSt

gnarender123@gmail.com

edenderest

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee