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 件のコメント

Geoff Hayes
Geoff Hayes 2017 年 11 月 13 日
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)?
Dion Guek
Dion Guek 2017 年 11 月 13 日
編集済み: Jan 2017 年 11 月 13 日
My matlab version is 2017b student edition. Based on the attached picture above, the data can be a string. This is taken from the doumentation page from https://www.mathworks.com/help/thingspeak/thingspeakwrite.html

サインインしてコメントする。

 採用された回答

Christopher Stapels
Christopher Stapels 2017 年 12 月 20 日
編集済み: Christopher Stapels 2017 年 12 月 20 日

0 投票

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 件のコメント

Marc Hanssens
Marc Hanssens 2024 年 6 月 4 日
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
Christopher Stapels 2024 年 6 月 4 日
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);

サインインしてコメントする。

その他の回答 (0 件)

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

ヘルプ センター および File Exchange で Data Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by