changes from zurich; my mac
This commit is contained in:
40
Functions/moveit_wrapper_.m
Normal file
40
Functions/moveit_wrapper_.m
Normal file
@@ -0,0 +1,40 @@
|
||||
function [data_out, state_out] = moveit_wrapper(func_name, data_in, para)
|
||||
% Generic wrapper for legacy MATLAB functions using loop-based execution
|
||||
%
|
||||
% Usage:
|
||||
% [data_out, state_out] = wrapper('quantize', data_in, para);
|
||||
%
|
||||
% Inputs:
|
||||
% - func_name: Name of the function as a string (e.g., 'quantize')
|
||||
% - data_in: Input signal or empty for initialization
|
||||
% - para: Structure with parameters (optional)
|
||||
%
|
||||
% Outputs:
|
||||
% - data_out: Processed output signal
|
||||
% - state_out: Internal state of the function
|
||||
|
||||
global loop;
|
||||
|
||||
% Ensure the function exists
|
||||
if ~exist(func_name, 'file')
|
||||
error('Function "%s" does not exist.', func_name);
|
||||
end
|
||||
|
||||
% Step 1: Get default parameters if not provided
|
||||
if nargin < 3 || isempty(para)
|
||||
loop = 0; % Request parameter structure
|
||||
[para, comment] = feval(func_name);
|
||||
end
|
||||
|
||||
% Initialize state
|
||||
state = struct();
|
||||
|
||||
% Step 2: Initialize the function
|
||||
loop = 0;
|
||||
[~, state_] = feval(func_name, data_in, state, para);
|
||||
|
||||
% Step 3: Process input signal
|
||||
loop = 1;
|
||||
[data_out, state_out] = feval(func_name, data_in, state_, para);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user