openfig has the error 'The value of 'Filename' is invalid. It must satisfy the function: ischar.'

7 次查看(过去 30 天)
I am opening figures in a loop but I get error
Error using openFigure
The value of 'Filename' is invalid. It must satisfy the function: ischar.
Error in openfig>localGetFileAndOptions (line 98)
ip.parse(args{:});
Error in openfig (line 37)
[filename, reuse, visibleAction] = localGetFileAndOptions(varargin);
f_range_name = [ {'MI_.5Hz.fig'}, {'MI_.525.fig'}, {'MI_.55.fig'}, ...
{'MI_.575.fig'}, {'MI_.6.fig'}];
for j = 1:length(temp_f)
[~,I]= min(f_range - temp_f(j));
openfig((f_range_name(I)))
hold on
plot(temp_f(j), temp_d(j), temp_k(j), 'o',...
'MarkerEdgeColor','k','MarkerFaceColor', 'b', ...
'MarkerSize', 9)
savefig(['MI_' num2str(f_range(I)) 'Hz.fig'])
close all
end
  1 个评论
Stephen23
Stephen23 2018-8-16
This is a pointlessly complex way to define a cell array:
f_range_name = [ {'MI_.5Hz.fig'}, {'MI_.525.fig'}, {'MI_.55.fig'}, {'MI_.575.fig'}, {'MI_.6.fig'}];
Simpler:
f_range_name = {'MI_.5Hz.fig', 'MI_.525.fig', 'MI_.55.fig', 'MI_.575.fig', 'MI_.6.fig'};

请先登录,再进行评论。

采纳的回答

Stephen23
Stephen23 2018-8-16
编辑:Stephen23 2018-8-16
You used the wrong indexing for the cell array. You need to use curly braces:
openfig((f_range_name{I}))
^ ^ curly braces to access the contents of a cell array!
The difference is simple:
  • {} curly braces access the cell contents.
  • () parentheses access the cells themselves.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by