function-handle

Cannot pass function handle as an argument of a function

血红的双手。 提交于 2019-12-25 03:41:19
问题 I'm new to Matlab and I'm trying to write custom function in matlab that would take function handle as one of its arguments. I'm getting this error all the time: Error using subsindex Function 'subsindex' is not defined for values of class 'function_handle'. Trying to debug I performed following test: I run command x = fminbnd(@humps, 0.3, 1) . I proceeded as expected - I got result x = 0.6370 . So I created custom function called train and I copied ALL the code of function fminbnd to the

why do i get fminsearch undefined function error [closed]

时间秒杀一切 提交于 2019-12-24 06:29:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . I'm trying to optimize a function with 2 inputs. Trying to use fminsearch but it keeps saying undefined function or variable although it is already defined. I have already defined the function in a separate script that is in the same directory with my main script. I have a classroom license which includes

Is it possible to test a function handle without try block?

删除回忆录丶 提交于 2019-12-21 17:19:50
问题 Is is possible to replace the following code with something which does not use exceptions? The handle x is a provided handle. I want to test it for validity (having actual code to back the handle) before use. x = @notreallyafunction; try x(); catch disp('Sorry function does not exist.'); end 回答1: To test function handles such as for screening out the bogus x=@notreallyafunction in your question, you can use the functions command to check the handle and get the referenced function's name, type

ezplot in MATLAB, how to plot using a function handle?

亡梦爱人 提交于 2019-12-12 06:07:43
问题 I've tried this: linefunca = @(xa,ya) aa*xa + ba*ya + ca; figure(1) imshow(Pica); hold on; ezplot(linefunca,[1,1072,1,712]); But I'm returned with this error: In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ezplotfeval/applyfun (line 80) z(i) = feval(f,x(i),y(i)); Error in ezplotfeval (line 65) z = applyfun(x,y); Error in ezplot>ezimplicit (line 257) u = ezplotfeval(f, X, Y); Error in ezplot (line 153) hp = ezimplicit(cax, f{1}, vars, labels, args{:});

Error using fzero in Matlab: Undefined function or method 'det' for input arguments of type 'function_handle'

为君一笑 提交于 2019-12-11 08:08:39
问题 I have the same kind of problem described in this topic: Using fzero: Undefined function or method 'isfinite' for input arguments of type 'sym' Their answers really helped me, but I am still stuck. I also have to find the zeros of a function of w, this function is defined in several steps: So the only unknown is w, and I defined other objects such as: lambda= @(w) ((16*rho(i)*A(i)*w^2*Lprime(i)^2)/(E(j)*I(i)))^0.25; beta=@(w) lambda*b(i)^0.5; gamma=@(w) lambda*Lprime(i)^0.5; Then, I define a