How to call MATLAB function in Thingspeak Matlab Analysis | MATLAB | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
How to call MATLAB function in Thingspeak Matlab Analysis
No permission to create posts
October 15, 2015
2:40 am
Avatar
jimmyjiangyq

Silver
Members
Forum Posts: 5
Member Since:
October 9, 2015
sp_UserOfflineSmall Offline

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

October 21, 2015
2:34 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

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

October 22, 2015
1:34 pm
Avatar
gamerji
New Member
Members
Forum Posts: 4
Member Since:
August 12, 2015
sp_UserOfflineSmall Offline

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.

October 22, 2015
7:45 pm
Avatar
jimmyjiangyq

Silver
Members
Forum Posts: 5
Member Since:
October 9, 2015
sp_UserOfflineSmall Offline

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

October 31, 2015
8:46 pm
Avatar
rkgarg

Silver
Members
Forum Posts: 8
Member Since:
February 21, 2015
sp_UserOfflineSmall Offline

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.

November 2, 2015
8:10 pm
Avatar
rw950431

Top
Members
Forum Posts: 261
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

@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.

November 3, 2015
10:21 am
Avatar
Hans
Natick, MA

Admin
Forum Posts: 396
Member Since:
January 18, 2011
sp_UserOfflineSmall Offline

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

November 3, 2015
10:54 am
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

Thanks for sharing your idea rw950431!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: dennis55
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

josephrj11, dennis55, jillhp4, tabathawg69, MarinaMa, Susandom

Administrators: Hans: 387, lee: 457