Output argument (and maybe others) not assigned during call to

1 回表示 (過去 30 日間)
MARIA RODRIGUEZ SANZ
MARIA RODRIGUEZ SANZ 2018 年 6 月 28 日
回答済み: MARIA RODRIGUEZ SANZ 2018 年 6 月 28 日
Hello! I am getting the following error message when running this function:
Output argument "gfp_colormap" (and maybe others) not assigned during call to "gfp_colormap".
Error in globalmergedplot (line 15) data_rgb =[data_rgb,ind2rgb(datos{n},gfp_colormap)];
When I simply replace my own colormaps (gfp_colormap and dapi_colormap) for some default colormaps of MATLAB (for example winter or spring) everything goes right.... Why the function does not recognize my colormaps (they work perfect out of this function)???. Any Ideas? Thanks in advanced!
%MYFUNCTION:
function globalmergedplot(datos)
load gfp_colormap
load dapi_colormap
load red_colormap
%CONVERTIMOS TODAS LAS IMÁGENES A RGB SEGÚN SU MARCADOR
data_rgb={};
for n=1:length(datos)
impar=mod(n,2)
if impar==1
data_rgb =[data_rgb,ind2rgb(datos{n},gfp_colormap)];
else
data_rgb =[data_rgb,ind2rgb(datos{n},dapi_colormap)];
end
end
%HACEMOS UN MERGE DE LOS CHANNELS DE TODAS LAS IMAGENES POR PAREJAS.
data_merged={};
for n=1:length(data_rgb)
impar=mod(n,2)
if impar==1
data_merged=[data_merged,imadd(data_rgb{n},data_rgb{n+1})];
else
end
end
%VISUALIZAMOS EL PLOT DE RESULTADO CON LA FUNCION IMDISP.
output=figure(1),
plot_merged=imdisp(data_merged,'Border',[0.01 0.01]);
end

回答 (3 件)

Walter Roberson
Walter Roberson 2018 年 6 月 28 日
You are "poofing" variables into existence and that is confusing MATLAB.
This will not be fixed in MATLAB: MATLAB is deliberately moving towards making those situations errors.
To get around the problem, before your lines
load gfp_colormap
load dapi_colormap
load red_colormap
add the lines
gpf_colormap = []; dapi_colormap = []; red_colormap = [];
That will force MATLAB to understand the names as being the names of variables,
  1 件のコメント
Stephen23
Stephen23 2018 年 6 月 28 日
編集済み: Stephen23 2018 年 6 月 28 日
Using function syntax rather than command syntax is a much better habit to learn and is totally unambiguous:
S = load(...);

サインインしてコメントする。


Stephen23
Stephen23 2018 年 6 月 28 日
編集済み: Stephen23 2018 年 6 月 28 日
Rather than magically making variables appear in the workspace, always load into an output variable:
S = load('gfp_colormap.mat');
...
S.gfp_colormap

MARIA RODRIGUEZ SANZ
MARIA RODRIGUEZ SANZ 2018 年 6 月 28 日
Thank you very much for your help! Now it works perfect!

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Raspberry Pi Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by