Thingspeakwrite error when using string array
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dion Guek
le 13 Nov 2017
Commenté : Christopher Stapels
le 4 Juin 2024
This string of code is taken from the thingSpeak documentation for matlab. I just copy and paste but still got this error. I would very much appreciate it if anyone can tell me where i did wrong

2 commentaires
Geoff Hayes
le 13 Nov 2017
Dion - which version of MATLAB are you using? If you type doc thingSpeakWrite what does the documentation say about the data (second) input (are strings allowed)?
Réponse acceptée
Christopher Stapels
le 20 Déc 2017
Modifié(e) : Christopher Stapels
le 20 Déc 2017
When you write string data to ThingSpeak, it generally wants to have a cell array. You should not usually need to do the String() conversion yourself. Try
thingSpeakWrite(349672,{ans},'Location',[-40,23],'WriteKey',writeKey);
and
thingSpeakWrite(channelID,{2.3,'on','good'},'Location',[-40,23],'WriteKey',writeKey);
Ill have a look at fixing that documented example, thanks for pointing it out.
2 commentaires
Marc Hanssens
le 4 Juin 2024
what about with arrays? EG: dA,dB & dC are arrays of Doubles and sD is an array of strings
thingSpeakWrite(writeChannelID,'Fields',[1,2,3,4],'Values', [ dA, dB, dC, sD ], 'WriteKey', writeAPIKey, 'TimeStamp',tStamp);
Christopher Stapels
le 4 Juin 2024
Generally, the field values cannot be arrays. You can write them as strings or cell arrays.
thingSpeakWrite(writeChannelID,'Fields',[1,2,3,4],'Values', [ {dA}, {dB}, {dC}, {sD} ], ...
'WriteKey', writeAPIKey, 'TimeStamp',tStamp);
Plus de réponses (0)
Communautés
Plus de réponses dans ThingSpeak Community
Voir également
Catégories
En savoir plus sur Read Data from Channel 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!
