Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

My code is not able to fit some data on a graph

1 vue (au cours des 30 derniers jours)
Gamra Samha
Gamra Samha le 3 Juil 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi,
I have written a code to analyse series of dicom images from selected 3 ROIs from each image, fit their average measurements exponentially in one graph , and then plotting the results.
The code runs well for all parts except when it reachs the fit command it just does not work. I do not get any error messages, but when I run the code on that specific 'fit line', I get this command: error Fcn = iCreateError Function (nargout >4).
I really do not understand what is happening. Can someone help me please by resolving this problem?
The code is below:
xzdxbnfile_name={'E:\copied folders from CD A-H_IRONQUANTI\1818000'};
clear all
%Which image to display for selecting region
Num = 18;
dirName = pwd; %# folder path
files = dir( fullfile(dirName,'*') );
files = {files.name}'; %'# file names
files = files(3:end);
a=mat2gray(dicomread(fullfile(dirName,files{Num})));
y = [];
jj = 1;
N = 3;
figure(1);
im = imshow(a);
meanInt = [];
%%y = [];
for ii = 1:N
%%create an ROI
e = imellipse(gca,[]);
BW = createMask(e);
for k = 30:41
fname = fullfile(dirName,files{k}); %# full path to file
avoidMe = strcmp(fname,'forFilesInDir.m');
if ~avoidMe
diimg = dicomread(fname);
if ~isempty(diimg)
meanReg = diimg(BW);
meanInt(k) = mean(meanReg);
else
meanInt(k) = 0;
end
end
y(jj) = meanInt(k);
%%y = meanInt(k);
jj = jj+1;
end
end
g = y(1:12)';
h = y(13:24)';
m = y(25:36)';
x = [0.9,2,3,4.1,5.2,6.2,7.3,8.4,9.5,10.5,11.6,12]';
options = fitoptions('exp1');
options.Normalize = 'on';
options.Algorithm = ('Levenberg-Marquardt');
options.StartPoint = [209.356287641061 -0.223283499455681];
%f1 = fit(x,g,'exp1',options);
figure
f1 = fit(x,g, 'exp1', options);
hold on
f2 = fit(x,h,'exp1', options);
%plot(x,h,'b-');
hold on
f3 = fit(x,m,'exp1', options);
plot(x,g,'r', x,h,'g',x,m, 'b');

Réponses (0)

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by