【ci框架】自定义扩展的核心控制器类MY_Controller

<?php
class MY_Controller extends CI_Controller{

	//构造函数:在构造函数中判断用户是否已经登陆,如果登陆,可进入后台控制器,返回跳转到登陆页面
	public function __construct(){
		parent::__construct();
		$this->load->helper("url");
		$this->load->model("user_model");//user_model模型类实例化对象
		$this->cur_user=$this->user_model->is_login();//检测是否登陆,如果登陆,返回登陆用户信息,否则返回false
		if($this->cur_user === false){
			header("location:".site_url("common/login"));
		}else{
			//如果已经登陆,则重新设置cookie的有效期
			$this->input->set_cookie("username",$this->cur_user['username'],60);
			$this->input->set_cookie("password",$this->cur_user['password'],00);
			$this->input->set_cookie("user_id",$this->cur_user['user_id'],60);
		}
	}

}
?>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
这段代码里有什么错误,帮我找出来并给出改正后的代码% 设定恒温箱温度范围 T_min = 18; T_max = 24; % 设定PID控制器参数 Kp = 1.2; Ki = 0.5; Kd = 0.1; % 设定BP神经网络控制器参数 hidden_layer_size = 10; max_epochs = 1000; learning_rate = 0.01; % 生成随机温度信号作为输入 t = 0:0.1:100; input_signal = T_min + (T_max - T_min) * rand(size(t)); % 初始化PID控制器 pid_controller = pid(Kp, Ki, Kd); % 初始化BP神经网络控制器 bp_controller = fitnet(hidden_layer_size); bp_controller.trainParam.epochs = max_epochs; bp_controller.trainParam.lr = learning_rate; % 设定仿真时间步长 dt = 0.1; % 初始化温度和控制器输出变量 current_temperature = T_min; pid_output = 0; bp_output = 0; % 开始仿真循环 for i = 1:length(t) % 计算PID控制器输出 pid_output = pid_controller(current_temperature, input_signal(i)); % 训练BP神经网络控制器 bp_controller = train(bp_controller, current_temperature, input_signal(i)); % 计算BP神经网络控制器输出 bp_output = bp_controller(current_temperature); % 计算当前温度 current_temperature = current_temperature + (pid_output + bp_output) * dt; % 保证温度在设定范围内 if current_temperature < T_min current_temperature = T_min; elseif current_temperature > T_max current_temperature = T_max; end % 输出当前时间、输入信号、PID输出、BP神经网络输出和当前温度 fprintf('Time: %f, Input: %f, PID Output: %f, BP Output: %f, Temperature: %f\n', t(i), input_signal(i), pid_output, bp_output, current_temperature); end
最新发布
06-10

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值