Challenge

Project 1- Traffic Jam Assistant Feature

here we had modules the system as given information 

it will have 2 blocks then 1 is Q1 then Q2 

Q1 will be formulated as given those things 

Q2 will be given as if in the given condition 

 Here wh have created as if in the given Data 

we need to change those things to get the code 

This is what we receive the code

cademic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * File: week_7_1.c
 *
 * Code generated for Simulink model 'week_7_1'.
 *
 * Model version                  : 1.11
 * Simulink Coder version         : 9.7 (R2022a) 13-Nov-2021
 * C/C++ source code generated on : Sat Oct  1 01:38:10 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives:
 *    1. Execution efficiency
 *    2. RAM efficiency
 * Validation result: Not run
 */

#include "week_7_1.h"
#include "rtwtypes.h"

/* External inputs (root inport signals with default storage) */
ExtU rtU;

/* External outputs (root outports fed by signals with default storage) */
ExtY rtY;

/* Model step function */
void week_7_1_step(void)
{
  /* Switch: '/Switch' incorporates:
   *  Inport: '/Input_Switch'
   *  Inport: '/Input_Voltage'
   *  Inport: '/VOLTAGE_MAXIMUM_RANGE'
   *  Inport: '/VOLTAGE_MINIMUM_RANGE'
   *  Logic: '/Logical Operator'
   *  Logic: '/Logical Operator1'
   *  RelationalOperator: '/Less Than'
   *  RelationalOperator: '/Less Than1'
   */
  if ((!rtU.Input_Switch) && ((rtU.Input_Voltage <= rtU.VOLTAGE_MINIMUM_RANGE) >=
       (int32_T)rtU.VOLTAGE_MAXIMUM_RANGE)) {
    real_T tmp;

    /* Saturate: '/Saturation' incorporates:
     *  Inport: '/Enable_Display'
     */
    if (rtU.Enable_Display > 7.0) {
      tmp = 7.0;
    } else if (rtU.Enable_Display < 0.0) {
      tmp = 0.0;
    } else {
      tmp = rtU.Enable_Display;
    }

    /* End of Saturate: '/Saturation' */

    /* MultiPortSwitch: '/Multiport Switch' */
    switch ((int32_T)tmp) {
     case 0:
      /* Outport: '/Output_Display' incorporates:
       *  Constant: '/Constant'
       */
      rtY.Output_Display = 1.0;
      break;

     case 1:
      /* Outport: '/Output_Display' incorporates:
       *  Constant: '/Constant'
       */
      rtY.Output_Display = 1.0;
      break;

     case 2:
      /* Outport: '/Output_Display' incorporates:
       *  Constant: '/Constant2'
       */
      rtY.Output_Display = 2.0;
      break;

     case 3:
      /* Outport: '/Output_Display' incorporates:
       *  Constant: '/Constant2'
       */
      rtY.Output_Display = 2.0;
      break;

     default:
      /* Outport: '/Output_Display' incorporates:
       *  Constant: '/Constant3'
       */
      rtY.Output_Display = 3.0;
      break;
    }

    /* End of MultiPortSwitch: '/Multiport Switch' */
  } else {
    /* Outport: '/Output_Display' incorporates:
     *  Constant: '/Constant5'
     */
    rtY.Output_Display = 0.0;
  }

  /* End of Switch: '/Switch' */
}

/* Model initialize function */
void week_7_1_initialize(void)
{
  /* (no initialization code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */

Model report will look like this 

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.