如何在 scilab

如何解决如何在 scilab

你好吗。我一整天都在尝试执行以下操作:我正在设计一个 PID 控制器,并根据我想要分析的数据量,然后我在同一个图中只显示一个或四个图(最后一个多图是用子图制作的).

所有计算和绘图都在一个函数中完成,函数中的选项取决于我想看到的内容,我正在编码的应用程序中有几个按钮和文本输入,并且正确了解 PID 设计和简单或多个地块正在运行;我当前的程序是轴句柄被分配给函数内部的局部变量,当然当程序退出函数时,这个变量会被破坏。

问题的更详细解释如下:如果我选择多个绘图然后我想要一个绘图那么我不知道如何删除四个轴来清理图形而不关闭它,所以当我想激活简单图然后程序只擦除四个图之一并在其余三个图上打印简单图,而其余三个子图保持可见。以下是给我带来问题的一段代码:

grafico=sistem_graf;
disp(grafico);
if(isdef('aa')==%T);
    scf(aa);
    delete(get("current_axes"));
    disp("aa");
end
if(isdef('bb')==%T);
    scf(bb);
    delete(get("current_axes"));
    disp("bb");
end
if(isdef('cc')==%T);
    scf(cc);
    delete(get("current_axes"));
    disp("cc");
end
if(isdef('dd')==%T);
    scf(dd);
    delete(get("current_axes"));
    disp("dd");
end

select ventana
case 0
    tipoG=0;
    plot2d(T,graffta);
    xtitle('Ω(S)/R(S): Respuesta al escalón (Sistema original)','t [s]','Vel [rpm]'); 
    legend(['Original';'C/control P';'C/Control PI';'C/Control PID']);
    aa=get("current_axes");
    aa.axes_bounds = [1/3 0 2/3 1];
case 1
    tipoG=1;        
//        delete(get("current_axes"));        
    plot(T,[graffta;sist_P_ZN;sist_PI_ZN;sist_PID_ZN]);
    xtitle('Ω(S)/R(S): Respuesta al escalón','Vel [rpm]'); 
    legend(['Original';'C/control P';'C/Control PI';'C/Control PID']);
    aa=get("current_axes");
    aa.axes_bounds=[1/3 0 2/3 1];
case 2
    tipoG=2;        
    //delete(get("current_axes"));  
    subplot(421);
    plot(T,'Vel [rpm]'); 
    legend(['Original';'C/control P';'C/Control PI';'C/Control PID']);
    aa=get("current_axes");
    aa.axes_bounds=[1/3,1/3,1/2]
    subplot(422);
    plot2d(T,(kt*kp/(j*la))*(1/(afta*bfta))*(1+(1/(afta-bfta))*(bfta*exp(-afta*T)-afta*exp(-bfta*T))));
    xtitle('Ω(t)','Vel [rpm]');
    bb=get("current_axes");
    bb.axes_bounds=[2/3,1/2];
    subplot(423);
    plot2d(T,(kt/(j*la))*(1/(afta*bfta))*((1/(afta-bfta))*(bfta*afta*exp(-bfta*T)-afta*bfta*exp(-afta*T))));
    xtitle('Variación de velocidad angular dΩ/dt','Ac. [rpm/s^2]');
    cc=get("current_axes");
    cc.axes_bounds=[1/3,1/2,1/2];
    subplot(424);
    plot(T,[sist_P_ZN;sist_PI_ZN;sist_PID_ZN]);
    xtitle('Controladores','Vel [rpm]');
    legend(['C/control P';'C/Control PI';'C/Control PID']);
    dd=get("current_axes");
    dd.axes_bounds=[2/3,1/2];
end

四个 if(isdef("variable_name")) 永远不起作用,因为当程序进入函数时,这些变量还不存在,这些变量是在带有 subplot 的图之后创建的。

如果从图形的编辑菜单中显示图形属性,则显示所有子轴,但如果我尝试使用例如获取轴

a=get(sistem_graf.Axes(1))

然后显示控制台显示属性“Axes”不存在,所以我不知道如何解决问题。

请帮忙!

提前致谢。

2021 年 3 月 6 日更新:

我找到了一种方法可以让我需要的行为以 90% 的速度工作,它只会在我从详细绘图变为简单绘图(正在擦除一个图形)时失败,但向后它工作正常,我之前更改了所有代码“选择ventana”到以下

if(imps(1) ~= -1)
    if(size(imps) == 1)
        sca(imps(1));
        disp(imps(1));
        delete(get("current_axes"));
    elseif(size(imps) > 1)
        sca(imps(1));
        delete(get("current_axes"));
        sca(imps(2));
        delete(get("current_axes"));
        sca(imps(3));
        delete(get("current_axes"));
        sca(imps(4));
        delete(get("current_axes"));
    end
end

并填充一个数组,其内容是上次调用该函数时绘制的所有轴,该数组从函数返回到一个全局变量,最后该全局变量在下一次调用中被提供给该函数并分配给局部变量“imps”。

我认为这有点疯狂,但显然 scilab 没有合并静态变量方法。

解决方法

如果我理解你的问题,下面的小例子应该对你有帮助:

function fun(nb)
    ch = gcf().Children;
    delete(ch(ch.type=="Axes"))
    t = linspace(0,1,100);
    if nb==1
        plot(t,t)
    else
        for i=1:nb
            subplot(2,2,i)
            plot(t,t.^i)
        end
    end
endfunction
clf
uicontrol("style","pushbutton","units","normalized","Position",[0.1 0.1 0.4 0.1],"string","one plot","callback","fun(1)");
uicontrol("style",[0.5 0.1 0.4 0.1],"four plots","fun(4)");

我认为您缺少的机制如下:

ch = gcf().Children;
delete(ch(ch.type=="Axes"))

即允许删除绘图轴并保持 uicontrols 活动的东西。上述构造使用逻辑索引。这里 ch.type=="Axes" 是一个布尔值向量,当对应组件 itype 字段为 ch(i) 时,组件 Axes 等于 true。然后,ch(ch.type=="Axes")ch 的组件子集,使得布尔索引的值为 true。因此,最后是 ch 类型的 Axes 组件的子集。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-