How to use private functions lib on ThingSpeak's matlab visualization like local Matlab program?
古いコメントを表示
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!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!