openfig has the error 'The value of 'Filename' is invalid. It must satisfy the function: ischar.'
9 次查看(过去 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
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!