when you use cd funtion and the message you get is MCC use of cd funtion is problematic, what do you do?

1 commentaire

Laura Proctor
Laura Proctor le 6 Avr 2011
Could you include the original code and error message?
MCC indicates that you are trying to use MATLAB Compiler. If that's the case, when you use CD, often you will want to use fully qualified path names when using CD.

Connectez-vous pour commenter.

 Réponse acceptée

Laura Proctor
Laura Proctor le 6 Avr 2011

0 votes

From Loren Shure's Blog on Writing Deployable Code by guest-blogger Peter Webb:
Don't rely on the current directory (cd) or changes to the MATLAB path (addpath) to control the execution of M-files. The path of a deployed application is determined at compiled time, and remains forever fixed. The current directory is never on the path in a deployed application. In the code below, cd-ing to the stringFcns directory does not make stringFcns/add shadow mathFcns/add. The order of these functions at runtime depends on what their order was at compile time. This causes errors.

3 commentaires

Suzzie
Suzzie le 6 Avr 2011
%script markfeatures.m
%for marking the eye and mouth positions in face images
%writes a file called labels.mat in which each row indexes an image and the
%columns are [x,y] position of the subjects eye (rigt and left) and the
%mouth.
imgdir = '/Users/suzzie/Desktop/FINAL CODE PROJECT 2011/FaceImages/';
destdir = '/Users/suzzie/Desktop/FINAL CODE PROJECT 2011/AlignFaceImages/';
cd(imgdir)
r = dir;
% get marks
marks = [];
for i = 3:(size(r,1))
t = r(i).name;
[X,map] = imread(t);
figure(1);
colormap gray;
if isfloat(X)
image(gray2ind(mat2gray((X))));
else
image(X);
end
title(t);
disp 'Click subject right eye, left eye, mouth'
[m,n] = ginput(3);
pos = round([m,n]);
pos = reshape(pos',1,6);
marks = [marks;pos]; %#ok<AGROW>
end
cd(destdir)
save labels marks r
Suzzie
Suzzie le 6 Avr 2011
this is the code
Aurelien Queffurust
Aurelien Queffurust le 7 Avr 2011
From your example , avoiding the CD function is easy
dir accepts a directory as input argument:
r = dir(imgdir);
do the same with the save function and destdir folder

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Compiler dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by