Documented name-value argument not recognized

조회 수: 5 (최근 30일)
Viktor
Viktor 2025년 8월 7일
답변: Steven Lord 2025년 8월 7일
Hi,
I want to specify the location where publish will save visdiff's output. I try to do this using
comp = visdiff(ancestor, fileName);
filter(comp, 'unfiltered');
report = publish(comp, 'outputDir', 'saved_reports/');
However, when running the above code, I this error message:
Error using comparisons.internal.api.PublishInputParser/parse
'outputDir' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for this function.
However, help publish produces the following:
Name-Value Arguments
Output Options
format - Output format
'html' (default) | 'doc' | 'latex' | 'ppt' | 'xml' | 'pdf'
outputDir - Output folder
character vector
stylesheet - Extensible Stylesheet Language (XSL) file
character vector
So why is outputDir not a recognized argument?
Best regards,
Viktor
  댓글 수: 4
Walter Roberson
Walter Roberson 2025년 8월 7일
Using 'outputDir' as a parameter works for me in R2024b and R2025a
sample = "disp('hello')";
tn = tempname() + ".m";
td = fileparts(tn);
addpath(td)
writelines(sample, tn)
publish(tn, 'outputDir', tempdir())
Viktor
Viktor 2025년 8월 7일
>> which publish -all
C:\Program Files\MATLAB\R2024b\toolbox\matlab\codetools\publish.p
publish is a Java method % com.mathworks.addons.sidepanel.Communicator method
C:\Program Files\MATLAB\R2024b\toolbox\matlab\connector2\messageservice\+message\+internal\MessageService.p % message.internal.MessageService method
C:\Program Files\MATLAB\R2024b\toolbox\simulink\comparisons\model\mldesktop\matlab\+slxmlcomp\SimulinkModelComparison.p % slxmlcomp.SimulinkModelComparison method
C:\Program Files\MATLAB\R2024b\toolbox\shared\comparisons\+comparisons\Comparison.p % comparisons.Comparison method
C:\Program Files\MATLAB\R2024b\toolbox\simulink\comparisons\model\mldesktop\matlab\+slxmlcomp\+internal\SimulinkModelComparison.p % slxmlcomp.internal.SimulinkModelComparison method

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

채택된 답변

Steven Lord
Steven Lord 2025년 8월 7일
The problem is that the documentation of publish is wrong. The correct name-value argument is outputFolder.
The problem is that you're looking at the documentation for the wrong publish function. You're looking at the documentation for the general publish function. The object returned by visdiff has its own publish method and it seems that method 1) is not documented as a separate function, just via the example on the visdiff documentation page and 2) uses slightly different name-value arguments from the general publish function.
Let's look at which publish function gets used for a difference object:
benchfile = which('bench.m'); % sample file
obj = visdiff(benchfile, benchfile);
which publish(obj) % ask which overload would be called by that command
/MATLAB/toolbox/comparisons/text/mldesktop/matlab/+comparisons/TextComparison.p % comparisons.TextComparison method
and which gets used for general publishing of a file:
which publish(benchfile)
/MATLAB/toolbox/matlab/codetools/publish.p
I'll note this discrepancy in the name-value argument support to the development staff.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by