The problem is that the documentation of publish is wrong. The correct name-value argument is outputFolder.
Documented name-value argument not recognized
10 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 7 Aug 2025
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())
Accepted Answer
Steven Lord
on 7 Aug 2025
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
and which gets used for general publishing of a file:
which publish(benchfile)
I'll note this discrepancy in the name-value argument support to the development staff.
0 Comments
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!