Cannot run with provided input arguments

33 次查看(过去 30 天)
Lakshmi
Lakshmi 2024-4-4,15:59
评论: Voss 2024-4-4,19:11
Hello everyone,
I am facing error while creating GUI in look_up function "Not enough input arguments".
function updateGraph(app, selectedLabel)
gm_id = 0:0.1:50;
id_w = look_up(app.nch, 'ID_W', 'GM_ID', gm_id, 'L', selectedLabel);
% Plot ID_W against GM_ID on the UIAxes component
semilogx(app.UIAxes, (id_w)*10^6, gm_id, 'DisplayName', ['L = ', num2str(selectedLabel)]);
title(app.UIAxes, selectedLabel);
xlabel(app.UIAxes, 'g_m/I_D [S/A]');
ylabel(app.UIAxes, 'I_D/W [A/m]');
end
error:Not enough input arguments.
Error in app1/updateGraph (line 42)
id_w = look_up(app.nch, 'ID_W', 'GM_ID', gm_id, 'L', selectedLabel);

回答(2 个)

Jon
Jon 2024-4-4,18:40
The error is coming from your call to a function named look_up. The error is telling you that you are not supplying this function with enough input arguments. You supply 6, apparently it wants more. Since look_up, is not a standard MATLAB function, it must either be something you wrote, or someone else wrote that you are using. As you don't supply the code for this function I can't give you further details, but you should check the code for your function named look_up, and when you call it be sure to match the list of arguments it is expecting with the ones your are supplying
  1 个评论
Voss
Voss 2024-4-4,19:11
I don't think the error is from look_up being passed too few arguments; you can always call a function with fewer arguments than are defined in its input argument list. Just calling the function like that doesn't cause an error; an error occurs inside the called function when an input is referred to which has not been passed in.
Example:
fun(1) % error doesn't happen here
% (it's ok to pass fewer arguments to fun
% than it expects - it's up to fun to handle that)
function fun(a,b)
disp([a,b]) % error happens here because b is undefined (fun is not
% handling missing arguments properly in this case)
end
In OP's case it looks to me like the error is in updateGraph, due to selectedLabel not having been passed in.

请先登录,再进行评论。


Voss
Voss 2024-4-4,18:52
Not enough inputs are given to updateGraph; it expects selectedLabel to be given, but it's not.
How are you calling updateGraph?

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by