submit
'parts' requires one of the following:
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
Error in submit (line 30)
submitWithConfiguration(conf);

3 Kommentare

Kasula varshini
Kasula varshini am 22 Jun. 2021
error in line 45
how to resolve it
Walter Roberson
Walter Roberson am 24 Jun. 2021
Install one of: Navigation Toolbox, Robotics System Toolbox, or Sensor Fusion and Tracking Toolbox. That will resolve the error. (You would then get a different error.)
The permanent solution is as others have describe:
  • download repaired files from your course software; or
  • edit the code so that it does not use parts as both a variable and the name of a function.
Mohammed Lafoui
Mohammed Lafoui am 18 Jul. 2021
I cannot submit all my exercices, error of path in windows!!!? how to repair this? please

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Abhishek Malik
Abhishek Malik am 22 Apr. 2020
Bearbeitet: Abhishek Malik am 22 Apr. 2020

6 Stimmen

This is happening because variable parts has the same name as of parts(conf) function in file ex1/lib/submitWithConfiguration.m
Make the following changes to resolve this :
Line 4 - parts_1 = parts(conf);
Line 92 - function [parts_1] = parts(conf)
Line 93 - parts_1 = {};
Line 98 - parts_1{end + 1} = part;
Basically, I've just renamed the variables.
Same thing is happening with one more variable, so make the following changes :
Line 66 - submissionUrl_1 = submissionUrl();
Line 68 - responseBody = getResponse(submissionUrl_1, body);
This should work!

18 Kommentare

Tom Mosher
Tom Mosher am 2 Mai 2020
I recommend you not change the script files.
Instead, download the correct set from the course resources.
There are different sets for MATlAB and Octave users.
Ramon Andino
Ramon Andino am 25 Mai 2020
When I click on the zip file , there is only one zip set. Not multiple.
Si Tong Ngo
Si Tong Ngo am 29 Mai 2020
same, is there a way to get the set for matlab?
lavanya s
lavanya s am 11 Jun. 2020
i changed it according to the following changes but it did not work for me
Harshad Koshti
Harshad Koshti am 21 Jul. 2020
it's not working..
Ivan Belikov
Ivan Belikov am 2 Aug. 2020
Also you have to change:
Line 22: response = submitParts(conf, email, token, parts_1);
Line 37: showFeedback(parts_1, response);
Satishkumar Bansode
Satishkumar Bansode am 25 Aug. 2020
Bearbeitet: Walter Roberson am 14 Sep. 2020
please replace the following code for ex1/lib/submitWithConfiguration.m. this will work 100%
function submitWithConfiguration(conf)
addpath('./lib/jsonlab');
parts_1 = parts(conf);
fprintf('== Submitting solutions | %s...\n', conf.itemName);
tokenFile = 'token.mat';
if exist(tokenFile, 'file')
load(tokenFile);
[email token] = promptToken(email, token, tokenFile);
else
[email token] = promptToken('', '', tokenFile);
end
if isempty(token)
fprintf('!! Submission Cancelled\n');
return
end
try
response = submitParts(conf, email, token, parts_1);
catch
e = lasterror();
fprintf('\n!! Submission failed: %s\n', e.message);
fprintf('\n\nFunction: %s\nFileName: %s\nLineNumber: %d\n', ...
e.stack(1,1).name, e.stack(1,1).file, e.stack(1,1).line);
fprintf('\nPlease correct your code and resubmit.\n');
return
end
if isfield(response, 'errorMessage')
fprintf('!! Submission failed: %s\n', response.errorMessage);
elseif isfield(response, 'errorCode')
fprintf('!! Submission failed: %s\n', response.message);
else
showFeedback(parts_1, response);
save(tokenFile, 'email', 'token');
end
end
function [email token] = promptToken(email, existingToken, tokenFile)
if (~isempty(email) && ~isempty(existingToken))
prompt = sprintf( ...
'Use token from last successful submission (%s)? (Y/n): ', ...
email);
reenter = input(prompt, 's');
if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
token = existingToken;
return;
else
delete(tokenFile);
end
end
email = input('Login (email address): ', 's');
token = input('Token: ', 's');
end
function isValid = isValidPartOptionIndex(partOptions, i)
isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
end
function response = submitParts(conf, email, token, parts)
body = makePostBody(conf, email, token, parts);
submissionUrl_1 = submissionUrl();
responseBody = getResponse(submissionUrl_1, body);
jsonResponse = validateResponse(responseBody);
response = loadjson(jsonResponse);
end
function body = makePostBody(conf, email, token, parts)
bodyStruct.assignmentSlug = conf.assignmentSlug;
bodyStruct.submitterEmail = email;
bodyStruct.secret = token;
bodyStruct.parts = makePartsStruct(conf, parts);
opt.Compact = 1;
body = savejson('', bodyStruct, opt);
end
function partsStruct = makePartsStruct(conf, parts)
for part = parts
partId = part{:}.id;
fieldName = makeValidFieldName(partId);
outputStruct.output = conf.output(partId);
partsStruct.(fieldName) = outputStruct;
end
end
function [parts_1] = parts(conf)
parts_1 = {};
for partArray = conf.partArrays
part.id = partArray{:}{1};
part.sourceFiles = partArray{:}{2};
part.name = partArray{:}{3};
parts_1{end + 1} = part;
end
end
function showFeedback(parts, response)
fprintf('== \n');
fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
for part = parts
score = '';
partFeedback = '';
partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
end
evaluation = response.evaluation;
totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
fprintf('== --------------------------------\n');
fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
fprintf('== \n');
end
% use urlread or curl to send submit results to the grader and get a response
function response = getResponse(url, body)
% try using urlread() and a secure connection
params = {'jsonBody', body};
[response, success] = urlread(url, 'post', params);
if (success == 0)
% urlread didn't work, try curl & the peer certificate patch
if ispc
% testing note: use 'jsonBody =' for a test case
json_command = sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, url);
else
% it's linux/OS X, so use the other form
json_command = sprintf('echo ''jsonBody=%s'' | curl -k -X POST -d @- %s', body, url);
end
% get the response body for the peer certificate patch method
[code, response] = system(json_command);
% test the success code
if (code ~= 0)
fprintf('[error] submission with curl() was not successful\n');
end
end
end
% validate the grader's response
function response = validateResponse(resp)
% test if the response is json or an HTML page
isJson = length(resp) > 0 && resp(1) == '{';
isHtml = findstr(lower(resp), '<html');
if (isJson)
response = resp;
elseif (isHtml)
% the response is html, so it's probably an error message
printHTMLContents(resp);
error('Grader response is an HTML message');
else
error('Grader sent no response');
end
end
% parse a HTML response and print it's contents
function printHTMLContents(response)
strippedResponse = regexprep(response, '<[^>]+>', ' ');
strippedResponse = regexprep(strippedResponse, '[\t ]+', ' ');
fprintf(strippedResponse);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Service configuration
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function submissionUrl = submissionUrl()
submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
end
KAOUTAR MOUHCINE
KAOUTAR MOUHCINE am 9 Sep. 2020
thank you so much ... it works
TIANXIN LI
TIANXIN LI am 14 Sep. 2020
It works to me. Thank you!
José Díaz
José Díaz am 28 Okt. 2020
It didn't work for me
Mike Ak
Mike Ak am 23 Dez. 2020
I did change all above but still get below error
>> submitWithConfiguration
Not enough input arguments.
Error in submitWithConfiguration (line 4)
parts_1 = parts(conf);
Mike Ak
Mike Ak am 23 Dez. 2020
I get the same error too even i did follow all above gudlines
>> submitWithConfiguration
Not enough input arguments.
Error in submitWithConfiguration (line 191)
parts_1 = parts(conf);
urvi vasisht
urvi vasisht am 9 Apr. 2021
error in line 94 is coming pls tell
Walter Roberson
Walter Roberson am 9 Apr. 2021
Bearbeitet: Walter Roberson am 9 Apr. 2021
You need to name a struct when you call submitWithConfiguration -- the "configuration" that you are submitting with! You cannot just call submitWithConfiguration by itself. The submit() function builds the configuration for you
Ajay Kumar
Ajay Kumar am 26 Apr. 2021
can u send the code
Ajay Kumar
Ajay Kumar am 26 Apr. 2021
Warning: Function Warning: Name is nonexistent or not a directory: /MATLAB Drive/./lib/jsonlab
> In path (line 109)
In addpath (line 86)
In addpath (line 49)
In submitWithConfiguration (line 2)
'parts' requires one of the following:
Automated Driving Toolbox
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
UAV Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
getting this error can anyone resolve it
Amitabh Kant
Amitabh Kant am 2 Jul. 2021
Also you have to change:
Line 22: response = submitParts(conf, email, token, parts_1);
Line 37: showFeedback(parts_1, response
Nick Tsui
Nick Tsui am 3 Aug. 2021
Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (6)

Peter Radi
Peter Radi am 11 Nov. 2019

1 Stimme

Just replace submitWithConfiguration.m's content with a previous version of it (like from ex4).
Nathan Abraham
Nathan Abraham am 4 Apr. 2020

1 Stimme

I changed the name of the function parts() to parts_1(). Try doing the same for the definition and the call for the function.
It seems that the name of the function parts in MATLAB is dedicated name to some other toolbox.
It worked for me.
Tnx

2 Kommentare

Tom Mosher
Tom Mosher am 2 Mai 2020
Better to download the correct set of programming exercise script files.
There are two sets available. MATLAB users should get the ones from the setup instructions for MATLAB Online in Week 2.
Ramon Andino
Ramon Andino am 25 Mai 2020
I am using zip download from week2

Melden Sie sich an, um zu kommentieren.

Walter Roberson
Walter Roberson am 21 Sep. 2019

0 Stimmen

parts is a function defined inside submitWithConfiguration

7 Kommentare

Prakhar Bhatnagar
Prakhar Bhatnagar am 21 Sep. 2019
I know, even I have the same file in the same path. But want to know why it is executing normally. As I have just downloaded and uploaded the zip file on matlab online and after unzipping I am trying to submit the code.
function submitWithConfiguration(conf)
% Note: has the "certificate" patch from Liran for Windows-like systems
addpath('./lib/jsonlab');
%keyboard
parts = parts(conf);
fprintf('== Submitting solutions | %s...\n', conf.itemName);
tokenFile = 'token.mat';
if exist(tokenFile, 'file')
load(tokenFile);
[email token] = promptToken(email, token, tokenFile);
else
[email token] = promptToken('', '', tokenFile);
end
if isempty(token)
fprintf('!! Submission Cancelled\n');
return
end
try
response = submitParts(conf, email, token, parts);
catch
e = lasterror();
fprintf( ...
'!! Submission failed: unexpected error: %s\n', ...
e.message);
fprintf('!! Please try again later.\n');
return
end
if isfield(response, 'errorMessage')
fprintf('!! Submission failed: %s\n', response.errorMessage);
else
showFeedback(parts, response);
save(tokenFile, 'email', 'token');
end
end
function [email token] = promptToken(email, existingToken, tokenFile)
if (~isempty(email) && ~isempty(existingToken))
prompt = sprintf( ...
'Use token from last successful submission (%s)? (Y/n): ', ...
email);
reenter = input(prompt, 's');
if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
token = existingToken;
return;
else
delete(tokenFile);
end
end
email = input('Login (email address): ', 's');
token = input('Token: ', 's');
end
function isValid = isValidPartOptionIndex(partOptions, i)
isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
end
function response = submitParts(conf, email, token, parts)
body = makePostBody(conf, email, token, parts);
submissionUrl = submissionUrl();
params = {'jsonBody', body};
%responseBody = urlread(submissionUrl, 'post', params);
[code, responseBody] = system(sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, submissionUrl));
response = loadjson(responseBody);
end
function body = makePostBody(conf, email, token, parts)
bodyStruct.assignmentSlug = conf.assignmentSlug;
bodyStruct.submitterEmail = email;
bodyStruct.secret = token;
bodyStruct.parts = makePartsStruct(conf, parts);
opt.Compact = 1;
body = savejson('', bodyStruct, opt);
end
function partsStruct = makePartsStruct(conf, parts)
for part = parts
partId = part{:}.id;
fieldName = makeValidFieldName(partId);
outputStruct.output = conf.output(partId);
partsStruct.(fieldName) = outputStruct;
end
end
function [parts] = parts(conf)
parts = {};
for partArray = conf.partArrays
part.id = partArray{:}{1};
part.sourceFiles = partArray{:}{2};
part.name = partArray{:}{3};
parts{end + 1} = part;
end
end
function showFeedback(parts, response)
fprintf('== \n');
fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
for part = parts
score = '';
partFeedback = '';
partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
end
evaluation = response.evaluation;
totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
fprintf('== --------------------------------\n');
fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
fprintf('== \n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Service configuration
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function submissionUrl = submissionUrl()
submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
end
Walter Roberson
Walter Roberson am 21 Sep. 2019
Try giving the command
restoredefaultpath
rehash toolboxcache
and then run the file again
Dan Cav
Dan Cav am 25 Sep. 2019
I'm having the same issue, attempted this without success. Has anyone solved this?
Thanks
Walter Roberson
Walter Roberson am 25 Sep. 2019
Dan Cav:
Could you confirm that you are using a submitWithConfiguration.m that defines function parts() around line 93 or so, and yet submitWithConfiguration is not able to find parts ?
What shows up for
which -all submitWithConfiguration
Mansi Patel
Mansi Patel am 12 Okt. 2019
hii,
I am getting the same error. I tried this command and its showing nothing.
still struggling for the right answer.
Please help.
thank you.
Walter Roberson
Walter Roberson am 13 Okt. 2019
Could you confirm that you are using a submitWithConfiguration.m that defines function parts() around line 93 or so ?
Mansi Patel
Mansi Patel am 13 Okt. 2019
Bearbeitet: Mansi Patel am 13 Okt. 2019
yes
in line 93 : parts = {};

Melden Sie sich an, um zu kommentieren.

Chris Waweru
Chris Waweru am 4 Jan. 2020

0 Stimmen

Hi am getting the same error. Someone please help.
submit()
'parts' requires one of the following:
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
Error in submit (line 45)
submitWithConfiguration(conf);
submit()
'parts' requires one of the following:
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
Error in submit (line 45)
submitWithConfiguration(conf);

3 Kommentare

Mike Ak
Mike Ak am 23 Dez. 2020
>> submitWithConfiguration
'parts' requires one of the following:
Automated Driving Toolbox
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
UAV Toolbox
Error in submitWithConfiguration (line 5)
parts = parts(conf);
Sai Tarun
Sai Tarun am 30 Mär. 2021
use parts_function(conf)

Melden Sie sich an, um zu kommentieren.

Narendra Wagdarikar
Narendra Wagdarikar am 8 Aug. 2020

0 Stimmen

submit()
'parts' requires one of the following:
Automated Driving Toolbox
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
Error in submit (line 40)
submitWithConfiguration(conf);

5 Kommentare

Narendra Wagdarikar
Narendra Wagdarikar am 8 Aug. 2020
isuue is related to coursera on line matlab assignment submition
Tom Mosher
Tom Mosher am 8 Aug. 2020
I recommend that questions on the Coursera "Machine Learning" course be posted on the course's Discussion Forum.
Mike Ak
Mike Ak am 23 Dez. 2020
I am trying to sumbit my assignment in Ng's Machine learning course using Matlab R2020b but get below error. It wont let me to the step of entering login email and token password. pls advise how to fix it.
>> submit()
'parts' requires one of the following:
Automated Driving Toolbox
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
UAV Toolbox
Error in submitWithConfiguration (line 4)
parts = parts(conf);
Error in submit (line 45)
submitWithConfiguration(conf);
Nimisha Nupur
Nimisha Nupur am 20 Mai 2021
Hi,
I followed the directions where I changed parts to parts_1, but when I submitted I get the following error.
Function: parts
FileName: /MATLAB Drive/machine-learning-ex3/ex3/lib/submitWithConfiguration.m
LineNumber: 94
Please correct your code and resubmit.
fline num 94 is :
for partArray = conf.partArrays
Hi Nimisha,
Please check all the references of 'parts' variable and replace in all places.
And also check 'submissionUrl = submissionUrl()'
replace 'submissionUrl_1 = submissionUrl()'
Check all the refences where we are calling submissionUrl and replace with submissionUrl_1
Hope this is helpful.
Thank you

Melden Sie sich an, um zu kommentieren.

Neha Ksheerasagar
Neha Ksheerasagar am 30 Okt. 2021

0 Stimmen

Function: makePostBody
FileName: /MATLAB Drive/3XAKHIYlRiuwChyGJQYrRw_f1356b38f0f341e89cfc3b3b44ae8ff1_ex2-octave/lib/submitWithConfiguration.m
LineNumber: 74
how to solve this...getting this error while submitting

1 Kommentar

Tom Mosher
Tom Mosher am 30 Okt. 2021
Please post your question on the Coursera discussion forum.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by