How to call a function correctly.

3 visualizaciones (últimos 30 días)
Cath
Cath el 11 de Mayo de 2017
Respondida: dpb el 11 de Mayo de 2017
I am trying to implement a forward-backward splitting problem onto matlab. I have got the following code so far:
function [iflowers]=flower_image()
RGB=imread('...flowers image.jpg');
flowers=double(rgb2gray(RGB));
alpha=0.05;
iters=1000;
iflowers=do_flower_image(flowers,alpha,iters);
end
but when I call
[phi_x,phi_y]=do_flower_image(flowers,alpha,iters)
when creating a new function, then it doesn't work.
I believe this is due to the call of the do_flower_image not matching with the outputs of the function but I am new to matlab and I don't really understand what this means?
I have read all the help for creating and calling functions but it hasn't really made it any clearer for me.

Respuesta aceptada

dpb
dpb el 11 de Mayo de 2017
[phi_x,phi_y]=do_flower_image(flowers,alpha,iters)
Well, if
iflowers=do_flower_image(flowers,alpha,iters);
worked (or at least didn't error) and the error in the other call is "too many outputs" or somesuch, then the function do_flower_image is written to output only one variable and you've asked for two.
The documentation/help for that function will explain what it does and its inputs/outputs; we can't know that...

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by