The problem is that the documentation of publish is wrong. The correct name-value argument is outputFolder.
Documented name-value argument not recognized
10 次查看(过去 30 天)
显示 更早的评论
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
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())
采纳的回答
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!