Output Argument not assigned during call

조회 수: 6 (최근 30일)
Jesse Swanson
Jesse Swanson 2020년 3월 11일
댓글: Peter O 2020년 3월 11일
Good afternoon everyone,
I've been tasked to create a fairly simple code (which I've done for the most part). The code always gives the correct answers, however the grader that I must submit to presents this error:
Output argument "MaxPower" (and maybe others) not assigned during call to "MaxPowerSolver".
function MaxPower = MaxPowerSolver(ElectricalData)
Power = ElectricalData(:,2).*ElectricalData(:,3);
MaxPower = max(Power);
end
Where Electrical data is given by [t,v,i] ([time, voltage, current]).
I can't seem to work this one out after googling and researching other people's similar problems.
Please help, thank you for your time.
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 11일
Somehow it is grading some other version of your code. Make sure you do not have any other function of the same name that it could be finding.
Peter O
Peter O 2020년 3월 11일
Yeah, you're certainly assigning the value to MaxPower. A couple of possibilities strike me:
Are you actually calling this particular function? Is it perhaps shadowed by something else on the path that has a different output assignment? Type:
which MaxPowerSolver
Or Is it potentially in the calling function? If it also calls a variable MaxPower but forgets to assign it, perhaps you're seeing an error meant for a different file? (e.g. its handling assigns to "maxPower" or "MaxPowe" by mistake.) Something maybe like:
function MaxPower = evalInputFunction(func, e_data)
%
MaxPowe = func(e_data) % This is the actual failure point
end
load the_data
passfail = zeros(1,numel(test_functions))
for ix = 1:numel(test_functions)
fx = test_functions(ix) % Your MaxPowerSolver is test_function(17), for instance
Pmx = evalInputFunction(fx, the_data)
if Pmax == Correct_P
passfail(ix) = 1
end

댓글을 달려면 로그인하십시오.

답변 (1개)

Piyush Lakhani
Piyush Lakhani 2020년 3월 11일
Hi Jesse,
The error you had mentioned will occured only in the case when the output Variable "MaxPower" is not assigned in the function but as i can see it should work fine.
You may try following function.
function MP = MaxPowerSolver(ElectricalData)
Power = ElectricalData(:,2).*ElectricalData(:,3);
MP = max(Power);
end
  댓글 수: 1
Jesse Swanson
Jesse Swanson 2020년 3월 11일
Thank you for your help, unfortunately this didn't resolve my issue as I believe it might be the automatic grading system which is at fault. Thank you for your time though.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by