MATLAB常见错误之plot画图失败

这篇具有很好参考价值的文章主要介绍了MATLAB常见错误之plot画图失败。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

错误使用 matlab.graphics.internal.newplotwrapper 尝试将 SCRIPT newplotwrapper 作为函数执行: C:\Program Files\Polyspace\R2020a\toolbox\matlab\graphics\+matlab\+graphics\+internal\newplotwrapper.m怎么解决

应该是动了newplotwrapper的内部代码

解决:

  1. 找到您的Matlab安装文件夹。在Windows上,默认情况下位于C:\Program Files\MATLAB\<MATLAB版本>

  2. 打开toolbox\matlab\graphics\@matlab\graphics\internal文件夹。在该文件夹中,您可以找到名为newplotwrapper.m的文件,这是Matlab中的newplot函数的实际实现。

  3. 更改为:function axReturn = newplot(hsave)
    %NEWPLOT Prepares figure, axes for graphics according to NextPlot.
    % H = NEWPLOT returns the handle of the prepared axes.
    % H = NEWPLOT(HSAVE) prepares and returns an axes, but does not
    % delete any objects whose handles appear in HSAVE. If HSAVE is
    % specified, the figure and axes containing HSAVE are prepared
    % instead of the current axes of the current figure. If HSAVE is
    % empty, NEWPLOT behaves as if it were called without any inputs.
    %
    % NEWPLOT is a standard preamble command that is put at
    % the beginning of graphics functions that draw graphs
    % using only low-level object creation commands. NEWPLOT
    % "does the right thing" in terms of determining which axes and/or
    % figure to draw the plot in, based upon the setting of the
    % NextPlot property of axes and figure objects, and returns a
    % handle to the appropriate axes.
    %
    % The "right thing" is:
    %
    % First, prepare a figure for graphics:
    % Clear and reset the current figure using CLF RESET if its NextPlot
    % is 'replace', or clear the current figure using CLF if its
    % NextPlot is 'replacechildren', or reuse the current figure as-is
    % if its NextPlot is 'add', or if no figures exist, create a figure.
    % When the figure is prepared, set its NextPlot to 'add', and then
    % prepare an axes in that figure:
    % Clear and reset the current axes using CLA RESET if its NextPlot
    % is 'replace', or clear the current axes using CLA if its NextPlot
    % is 'replacechildren', or reuse the current axes as-is if its
    % NextPlot is 'add', or if no axes exist, create an axes.
    %
    % See also HOLD, ISHOLD, FIGURE, AXES, CLA, CLF.


    % Copyright 1984-2015 The MathWorks, Inc.
    % Built-in function.


    if nargin == 0 || isempty(hsave)
    hsave = [];
    elseif ~isscalar(hsave) || ~ishghandle(hsave)
    error(message('MATLAB:newplot:InvalidHandle'))
    else
    % Make sure we have an object handle.
    hsave = handle(hsave);
    end




    fig = gobjects(0);
    ax = gobjects(0);


    if ~isempty(hsave)
    obj = hsave;
    while ~isempty(obj)
    if strcmp(obj.Type,'figure')
    fig = obj;
    elseif strcmp(obj.Type,'axes')
    ax = obj;
    end
    obj = obj.Parent;
    end
    end


    if isempty(fig)
    fig = gcf;
    end


    fig = ObserveFigureNextPlot(fig, hsave);


    % Set figure's NextPlot property to 'add' after obeying the previous setting.
    fig.NextPlot = 'add';


    checkNextPlot = true;
    if isempty(ax)
    ax = gca(fig);
    if isa(ax,'matlab.graphics.axis.PolarAxes')
    if ishold(ax)
    error(message('MATLAB:newplot:HoldOnMixing'))
    else
    ax = matlab.graphics.internal.swapaxes(ax,@axes);

    % We just creaetd a new axes, no need to check NextPlot
    checkNextPlot = false;
    end
    end
    elseif ~any(ishghandle(ax))
    error(message('MATLAB:newplot:NoAxesParent'))
    end


    if checkNextPlot
    ax = ObserveAxesNextPlot(ax, hsave);
    end


    if nargout
    axReturn = ax;
    end






    function fig = ObserveFigureNextPlot(fig, hsave)
    %
    % Helper fcn for preparing figure for nextplot, optionally
    % preserving specific existing descendants.
    % GUARANTEED to return a figure, even if some crazy combination
    % of create / delete fcns deletes it.


    switch fig.NextPlot
    case 'new'
    % if someone calls plot(x,y,'parent',h) and h is an axes
    % in a figure with NextPlot 'new', ignore the 'new' and
    % treat it as 'add' - just add the axes to that figure.
    if isempty(hsave)
    fig = figure;
    end
    case 'replace'
    clf(fig, 'reset', hsave);
    case 'replacechildren'
    clf(fig, hsave);
    case 'add'
    % nothing
    end
    if ~any(ishghandle(fig)) && isempty(hsave)
    fig = figure;
    end


    function ax = ObserveAxesNextPlot(ax, hsave)
    %
    % Helper fcn for preparing axes for nextplot, optionally
    % preserving specific existing descendants
    % GUARANTEED to return an axes in the same figure as the passed-in
    % axes, even if that axes gets deleted by an overzealous create or
    % delete fcn anywhere in the figure.


    % for performance only call ancestor when needed
    fig = ax.Parent;
    if ~strcmp(fig.Type,'figure')
    fig = ancestor(fig,'figure');
    end


    switch ax.NextPlot
    case 'replaceall';
    cla(ax, 'reset', hsave);
    case 'replace'
    % If there are multiple data spaces, ax.prepareForPlot() will do a
    % reset of the properties for the active data space (while
    % preserving other data spaces) and return false to indicate that a
    % full reset is not necessary. Otherwise, ax.prepareForPlot() will
    % return true.
    if (ax.prepareForPlot())
    cla(ax, 'reset', hsave);
    else
    cla(ax, hsave);
    end
    case 'replacechildren'
    cla(ax, hsave);
    case 'add'
    % nothing
    end


    if ~any(ishghandle(ax)) && isempty(hsave)
    if ~any(ishghandle(fig))
    ax = axes;
    else
    ax = axes('Parent',fig);
    end
    end文章来源地址https://www.toymoban.com/news/detail-617002.html

到了这里,关于MATLAB常见错误之plot画图失败的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • matlab绘图plot常用设置

    目录 图像的大小和位置 一个窗口画多张子图片 保存图片 MATLAB 中设置 Figure 和 Axes 的位置和尺寸 - 知乎 (zhihu.com) https://zhuanlan.zhihu.com/p/446968474 示例: plot(t,y, \\\'Color\\\', [0,0,1],\\\'Linewidth\\\',1.5); set(gca,\\\'Position\\\', [.13 .60 .80 .30]); set(gca,\\\'linewidth\\\',1.2,\\\'fontsize\\\',14,\\\'fontname\\\',\\\'Times\\\'); xlim([0 2.5]); yli

    2024年02月10日
    浏览(31)
  • matlab:plot线型和颜色

    线型选项: 实线:使用默认的plot命令绘制的线条就是实线。 虚线:可以使用“–”选项来绘制虚线。例如:plot(x,y,‘–’)。 点线:可以使用“:”选项来绘制点线。例如:plot(x,y,‘:’)。 点划线:可以使用“-.”选项来绘制点划线。例如:plot(x,y,‘-.’)。 颜色选项: Matla

    2024年02月05日
    浏览(26)
  • MATLAB绘图函数plot详解

    一、引言 Matlab软件提供了强大的可视化功能,可以根据给定的曲线上的坐标来绘制曲线图形,也可以根据已知的函数及自变量来绘制曲线图形,也可以只给定自变量的取值范围来绘制曲线,基本的Matlab函数是plot、fplot、ezplot、fimplicit等,本文详述利用plot绘制二维曲线图形的

    2024年02月12日
    浏览(41)
  • MATLAB plot绘图颜色及配色

    目录: 1.matlab中的默认缩写名称颜色; 2. 采用RGB三元组指定颜色; 3. 采用16进制颜色代码(只是用于2019a版本及以后版本); 4. 参考 1. matlab中的默认缩写名称颜色 plot绘图指定线条和数据标记点的颜色,可以采用matlab中的默认缩写名称的颜色,如下表所示: 颜色名称 缩写

    2024年02月12日
    浏览(27)
  • MATLAB | 如何用MATLAB如何绘制各式各样精致的三元相图(ternary plot)

    整了个大活,写了一个能够生成非常精致三元相图的函数,这种图主要用于展示三种变量之间的比例,本期实验绘制效果如下: 编写不易,这个工具写的脑壳痛,求多多点赞,依旧先介绍咋使用,工具函数放在最后,同时提供gitee及fileexchange下载链接,若是日后代码更改会在

    2024年02月01日
    浏览(95)
  • MATLAB科学绘图-MATLAB画图技巧与实例(一):常用函数

    Matlab拥有强大的绘图功能,内置了很多绘图函数,只需要给出一些基本参数就能得到所需图形,这类函数称为 高层绘图函数 。 此外,Matlab还提供了直接对图形句柄进行操作的 低层绘图操作 。这类操作将图形的每个图形元素(如坐标轴、曲线、文字等)看做一个独立的对象

    2024年02月03日
    浏览(34)
  • matlab画图(一、柱状图)

    🐋 前言:柱状图利用柱子的高度,反映数据的差异。肉眼对高度差异很敏感,辨识效果非常好。柱状图的局限在于只适用中小规模的数据集。 🐬 目录: 一、数据获取 二、简单柱状图 三、分组柱状图 四、堆叠柱状图 一、数据获取 统计图的绘制离不开数据的支撑。一般来说

    2024年01月20日
    浏览(44)
  • matlab画图方法(持续更)

    创建画布:figure(1);         % 在同一个脚本文件里面,要想画多个图,需要给每个图编号,否则只会显示最后一个图 plot(x, y, \\\'o\\\', new_x, p, \\\'r--\\\') plot(x1,y1,x2,y2)          在各个分块位置创建坐标区。 subplot(m,n,p)当前图窗划分为 m×n 网格,并在 p 指定的位置创建坐标区。   

    2024年02月12日
    浏览(31)
  • Matlab(画图进阶)

            目录 大纲  1.特殊的Plots 1.1 loglog(双对数刻度图) ​1.3 plotyy(创建具有两个y轴的图形)  1.4yyaxis(创建具有两个y轴的图) 1.5 bar 3D条形图(bar3) 1.6 pie(饼图) 3D饼图 1.7 polar  2.Stairs And Ste阶梯图  3.Boxplot 箱型图和Error Bar误差条形图 3.1 boxplot  3.2 errorbar  4.fill(创建二维填充补片

    2024年02月10日
    浏览(29)
  • Matlab 用矩阵画图

    本文汇总了 Matlab 用矩阵画图的几种方式。 关于 *.mat 文件 *.mat 文件是 matlab 的数据存储的标准格式,它是标准的二进制文件,还可以 ASCII 码形式保存和加载,在 MATLAB 中打开显示类似于单行 EXCEL 表格,加载和存储 mat 文件的语法: 用矩阵画图主要有如下几种方式: 下面是一

    2024年02月04日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包