Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 是否从uigetfile检索文本字符串?_Matlab - Fatal编程技术网

Matlab 是否从uigetfile检索文本字符串?

Matlab 是否从uigetfile检索文本字符串?,matlab,Matlab,"下午好,, 我一直在将数据加载到一个脚本中,我想让文件名成为图的标题,或者只是在某个可见的文本中。 我想不出来,任何建议都很感激。。。。 我正在运行的代码是: %% File selection [fileName, pathName] = uigetfile({'*_SUMMARY.mat' 'MAT-files (*_SUMMARY.mat)'}, 'Load Data', '.'); if pathName == 0, error('No file selected'), end lo

"下午好,, 我一直在将数据加载到一个脚本中,我想让文件名成为图的标题,或者只是在某个可见的文本中。 我想不出来,任何建议都很感激。。。。 我正在运行的代码是:

%% File selection

[fileName, pathName] = uigetfile({'*_SUMMARY.mat' 'MAT-files (*_SUMMARY.mat)'}, 'Load Data', '.');
if pathName == 0, error('No file selected'), end
load(fullfile(pathName,fileName))
%% Intercept and gradient
%-------c---------m------]
FR = [0.6051, -1.9666e-05;...   % zero
    0.60429, -1.8295e-05;...    % 60
    0.60576, -2.1043e-05;...    % 120
    0.60311, -1.5683e-05];      % 180
N = numel(FR(:,1));
% x-axis limits
x = linspace(1,1000,N)';    % Vector of [N] equally spaced points in range 0:1000
% End position as scalar value
idx = 102;  % Get data for sheet 102
V = 1:numel(SheetInkThickness(1,:));    % vector for 'x' values
FinalSheetSum = sum(SheetInkThickness(idx,:));  % sum
average = mean(SheetInkThickness(idx,:));   % mean
ActMinusAve = (SheetInkThickness(idx,:)-average).^2; % (Act-Ave).^2
sumActMinusAve = sum(ActMinusAve);  % Sum of Act-Ave
SheetInkProperties = [V', (SheetInkThickness(idx,:))', ActMinusAve'];   % matrix for storing ink sheet properties
[maxActMinusAve, idmaxActMinusAve] = max(ActMinusAve);  % max of ActMinusAve
[minActMinusAve, idminActMinusAve] = min(ActMinusAve);  % min of ActMinusAve
[maxSIT, idmaxSIT] = max(SheetInkThickness(idx,:));
[minSIT, idminSIT] = min(SheetInkThickness(idx,:));
[maxSIT2, idmaxSIT2] = max(ActMinusAve);
[minSIT2, idminSIT2] = min(ActMinusAve);
[p, S] = polyfit(V', SheetInkProperties(:,2),1);
[y,delta] = polyval(p,V',S);
StDev = std(SheetInkThickness(idx,:));
diff1 = (maxSIT-average);   % Difference between max and average
diff2 = (average-minSIT);   % Difference between min and average
if diff1>diff2;     % Find which difference is greater
    difference = diff1;
else difference = diff2;
end
%% Sheet ink thickness
fh5 = figure(5);
clf
hold on
grid on
subplot(2,2,3:4)
plot(V, ActMinusAve, 'b.-');
text(0.45, 0.9, ['maximum: ', num2str(maxSIT2)],...
    'units','normalized')
text(0.45, 0.85, ['minimum:  ', num2str(minSIT2)],...
    'units','normalized')
text(0.45, 0.8, ['System length:     ', num2str(Sum.Total_Length),' (mm)'],...
    'units','normalized')
text(0.45, 0.75, ['Number of rollers: ', num2str(Sum.NoOfRollers+1)],...
    'units','normalized')
text(0.45, 0.7, ['Number of nips:    ', num2str(Sum.NoOfNips)],...
    'units','normalized')
text(0.9, 0.85, {'{\it\Sigma(x-{\itxmean)^2} = }',...
    num2str(sumActMinusAve)},'units','normalized');
title('{\it(x-{\itxmean)^2}}');
xlabel('segments on sheet');
ylabel('ink thickness');
% Lower figure
subplot(2,2,1:2)
plot(V, SheetInkThickness(idx,:))
hold on
plot(V, average,'r-');
text(V(1,end),average,'average');
text(0.45, 0.9, ['average:       ', num2str(average)],...
    'units','normalized')
text(0.45, 0.85, ['difference:    ', num2str(difference)],...
    'units','normalized')
text(0.45, 0.8, ['Standard deviation:    ', num2str(StDev)],...
    'units','normalized')
text(idmaxSIT, maxSIT, ['\leftarrow max = ',num2str(maxSIT)]);
text(idminSIT, minSIT, ['\leftarrow min = ',num2str(minSIT)]);
title('sheet ink thickness')
xlabel('sheet length (segments)');
ylabel('ink thickness (um)');
是的,我知道这很混乱,当然也有机会循环/矢量化一些代码,但这是一项正在进行的工作。 有人能给我指出解决问题的正确方向吗? 谢谢
Richard

如果我理解你的要求,你可能想看看使用mfilename

例如,如果您想使用文件名作为图形标题,您可以使用

% File is named myScript.m
figure
axes
title(mfilename)

如果您想了解更多详细信息,请告诉我

非常好的知识-我真的很难使用正确的搜索词来查找信息。在谷歌上!一旦我把语法正确地记下来,它似乎工作得很好。