C中,函数调用返回值可否是两个数组
最近要将matlab程序改写成C.遇到返回值是两个不同数组的问题,不知如何解决.如下是matlab程序:function [x,q] = bootstrap(actualx,y,R,Q,initVar,numSamples);
[rows,cols] = size(y); % rows = Max number of time steps.
S = numSamples; % Number of samples;
Nstd = 2; % No of standard deviations for error bars;
x=zeros(S,rows);
xu=zeros(S,rows);
q=zeros(S,rows);
% SAMPLE FROM THE PRIOR:
% =====================
x(:,1) = sqrt(initVar)*randn(S,1);
mean(x(:,1));
cov(x(:,1));
% UPDATE AND PREDICTION STAGES:
% ============================
for t=1:rows-1,
xu(:,t) = predictstates(x(:,t),t,Q);
q(:,t+1) = importanceweights(xu(:,t),y(t+1,1),R);
x(:,t+1) = updatestates(xu(:,t),q(:,t+1));
end;
其中:输入变量actualx,y分别是50行1列的矩阵(数组);R,Q,initVar,numSamples是值变量;
输出变量x,q也是数组
在C中怎样能使返回值是两个不同的数组呢?
精通matlab和C的达人,看看怎样解决?