openfig has the error 'The value of 'Filename' is invalid. It must satisfy the function: ischar.'
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Stephen23
le 16 Août 2018
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'};
Réponse acceptée
Stephen23
le 16 Août 2018
Modifié(e) : Stephen23
le 16 Août 2018
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!