How to use private functions lib on ThingSpeak's matlab visualization like local Matlab program?
Show older comments
Hi all,
I would like to save my several functions once and use them in all my visualizations (as we would do it in every local Matlab program). However, I didn't find any way to do this on Thingspeak. My workaround is to copy+paste all my functions and parameters in every visualization code. This works, but it is not nice.
For example:
main program (source m-file):
% Simple test model to check compatiblity with ThingSpeak
I=[0 0 1 1 5 5 2 2 1 1]; % Assume this random signal simulates the cell current (input) in 10 seconds
for i=1:10
x=I(i);
V_ECM(i)=test_func(x,i); % solve the cell model ODE
end
plot(V_ECM) % plot to see if the model is executed correctly
function program (function m-file):
function y=test_func(x,i)
syms Vc(t)
ode=diff(Vc)+2*Vc==2*x; % Assume this is one diff equation in cell model
cond=Vc(0)==0; % assign initial conditions
Vcsol(t)=dsolve(ode,cond); % solve ODE with the given initial condition
y=Vcsol(i); % sent back calculation at current time stamp i to the main M-file
end
If I want to execute this example in one file on ThingSpeak visualization, it shows following error:
Program:
I=[0 0 1 1 5 5 2 2 1 1]; % Assume this random signal simulates the cell current (input) in 10 seconds
% Simple test model to check compatiblity with ThingSpeak
for i=1:10
x=I(i);
V_ECM(i)=test_func(x,i); % solve the cell model ODE
end
plot(V_ECM) % plot to see if the model is executed correctly
function y=test_func(x,i)
syms Vc(t)
ode=diff(Vc)+2*Vc==2*x; % Assume this is one diff equation in cell model
cond=Vc(0)==0; % assign initial conditions
Vcsol(t)=dsolve(ode,cond); % solve ODE with the given initial condition
y=Vcsol(i); % sent back calculation at current time stamp i to the main M-file
end
Error:
syms requires Symbolic Math Toolbox.
Error in Test>test_func (line 14)
syms Vc(t)
Error in Test (line 7)
V_ECM(i)=test_func(x,i); % solve the cell model ODE
Could anyone help on how can I call functions several time on ThingSpeak visualization like we do in Desktop Matlab program?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!