How to call MATLAB function in Thingspeak Matlab Analysis | 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
How to call MATLAB function in Thingspeak Matlab Analysis
Avatar
jimmyjiangyq

Silver
Forum Posts: 5
sp_UserOfflineSmall Offline
1
October 15, 2015 - 2:40 am
sp_Permalink sp_Print

Hi Helper,

I am a total green hand on Matlab stuff and I have a question about how I can call a MATLAB function in Thingspeak Matlab Analysis?

For example, I have a Matlab function as below:

Function [ data1, data2, parameter1, parameter2] = calculate_something(parameter1, parameter2, parameter3)

.......

Is there a way that I can call this function in Thingspeak Matlab Analysis's Matlab code?

This is very similar to call "ThingspeakRead" function in the current Matlab Analysis panel window. I am wondering if I can call a customized function in the panel window.

Thanks a lot for any comments in community.

Regards

Avatar
Adarsh_Murthy

Forum Posts: 59
sp_UserOfflineSmall Offline
2
October 21, 2015 - 2:34 pm
sp_Permalink sp_Print

Hi jimmyjiangyq,

At present, you will not be able to call custom functions from either the MATLAB Analysis App or the MATLAB Visualization App. Both the Apps only allow a MATLAB script to be written and this script can only call functions already defined in MATLAB. We will consider this capability for a future release.

As a workaround, you can move the logic in the 'calculate_something' function into each MATLAB Analysis/Visualization App that requires it, as a script.

Thanks,
Adarsh

Avatar
gamerji
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
October 22, 2015 - 1:34 pm
sp_Permalink sp_Print

If you have your function publicly hosted somewhere, then you can try urlwrite as follows -

urlwrite('http://pastebin.com/raw.php?i=FYQbPHWH','total.m');
total(23,10)

Hope that helps.

Avatar
jimmyjiangyq

Silver
Forum Posts: 5
sp_UserOfflineSmall Offline
4
October 22, 2015 - 7:45 pm
sp_Permalink sp_Print

Hi Adarsh and gamerji,

Thanks a lot for your comments. It seems like I may need to use standalone Matlab platform to do such task.

Jimmyjiangyq

Avatar
rkgarg

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
5
October 31, 2015 - 8:46 pm
sp_Permalink sp_Print sp_EditHistory

I am also facing problem using if function. I am getting current time using clock function. Then I want to do some check on time and based on the time I want to feed data to new channel. It appears if function does not work at all.

Update: I did not write end statement. It works.

Avatar
rw950431

Forum Posts: 252
sp_UserOfflineSmall Offline
6
November 2, 2015 - 8:10 pm
sp_Permalink sp_Print

@Adarsh_Murthy - if you are considering feature requests for future releases can I suggest passing URL parameters through to the matlab environment? This would allow more generic and re-usable code since you could specify a channel or field number in the URL and have matlab process it rather than have to hard-wire it into each block.

Avatar
Hans
Natick, MA

Forum Posts: 390
sp_UserOfflineSmall Offline
7
November 3, 2015 - 10:21 am
sp_Permalink sp_Print

This is a good idea for enhancing our MATLAB functionality. We will take a closer look at it. Thanks!

Avatar
Adarsh_Murthy

Forum Posts: 59
sp_UserOfflineSmall Offline
8
November 3, 2015 - 10:54 am
sp_Permalink sp_Print

Thanks for sharing your idea rw950431!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
26 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:

epicpaymentsny

DanielBobby

mercedeszw18

ujuxoketate

olihfez

winnieeq69

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee