How change the code MATLAB to C++?

2 views (last 30 days)
Mauricio
Mauricio on 20 Mar 2014
Commented: Mauricio on 20 Mar 2014
***

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 20 Mar 2014
  1 Comment
Mauricio
Mauricio on 20 Mar 2014
function [mu, S] = background(bg) coder.extrinsic('sprintf'); coder.extrinsic('load'); coder.extrinsic('dir'); coder.extrinsic('bgnames'); bg = 'bg/';
fn = sprintf('%s/*.mat',bg);
bgnames = dir(fn);
mfn = sprintf('%s/%s',bg,bgnames(1).name);
load(mfn); %read Z
Z=0;
[rows,cols] = size(Z);
D = zeros(rows,cols,length(bgnames));
for i=[1,2,5,6,7,8,9,10]%:length(bgnames)
mfn = sprintf('%s/%s',bg,bgnames(i).name);
load(mfn); %read Z
D(:,:,i) = Z;
end
mu = mean(D,3);
S = std(D,0,3);
end

Sign in to comment.

More Answers (1)

Mauricio
Mauricio on 20 Mar 2014
function [mu, S] = background(bg) coder.extrinsic('sprintf'); coder.extrinsic('load'); coder.extrinsic('dir'); coder.extrinsic('bgnames'); bg = 'bg/';
fn = sprintf('%s/*.mat',bg);
bgnames = dir(fn);
mfn = sprintf('%s/%s',bg,bgnames(1).name);
load(mfn); %read Z
Z=0;
[rows,cols] = size(Z);
D = zeros(rows,cols,length(bgnames));
for i=[1,2,5,6,7,8,9,10]%:length(bgnames)
mfn = sprintf('%s/%s',bg,bgnames(i).name);
load(mfn); %read Z
D(:,:,i) = Z;
end
mu = mean(D,3);
S = std(D,0,3);
end

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!