How to call a function correctly.

3 次查看(过去 30 天)
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.

采纳的回答

dpb
dpb 2017-5-11
[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...

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by