Skip to content

XiaoMaColtAI/math-modeling-skill / dsh-plugin/math-modeling-agent/skills/math-modeling/references/roles/编程手

编程手

Verified

数学建模的 Python 或 MATLAB 实现、运行、表格输出、可视化和复现阶段。

scripts/export_publication_figure.m

View on GitHub
function outputs = export_publication_figure(fig, outputStem, dpi, grayscalePreview, strictDesign)
%EXPORT_PUBLICATION_FIGURE 通过设计门禁后输出 SVG、PNG 与灰度质检图。
arguments
    fig (1,1) matlab.ui.Figure
    outputStem (1,1) string
    dpi (1,1) double {mustBeInteger,mustBeGreaterThanOrEqual(dpi,300)} = 300
    grayscalePreview (1,1) logical = true
    strictDesign (1,1) logical = true
end

[folder, name, ~] = fileparts(outputStem);
if strlength(folder) == 0
    folder = ".";
end
if ~isfolder(folder)
    mkdir(folder);
end
stem = fullfile(folder, name);
svgPath = stem + ".svg";
pngPath = stem + ".png";
fig.PaperPositionMode = "auto";
drawnow;
designIssues = audit_publication_figure(fig);
if strictDesign && ~isempty(designIssues)
    error("出版设计预检未通过:%s", join(designIssues, ";"));
end
exportgraphics(fig, svgPath, "ContentType", "vector");
exportgraphics(fig, pngPath, "Resolution", dpi);
outputs = struct("svg", svgPath, "png", pngPath);
if grayscalePreview
    qaFolder = fullfile(folder, "_qa");
    if ~isfolder(qaFolder)
        mkdir(qaFolder);
    end
    image = imread(pngPath);
    rgb = double(image(:,:,1:3));
    if isinteger(image)
        rgb = rgb / double(intmax(class(image)));
    end
    gray = 0.2126 * rgb(:,:,1) + 0.7152 * rgb(:,:,2) + 0.0722 * rgb(:,:,3);
    grayPath = fullfile(qaFolder, name + "_grayscale.png");
    imwrite(gray, grayPath);
    outputs.grayscale = grayPath;
end
end
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall