Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Differences in C Code Generation for Switch blocks between Matlab 2021b and Matlab 2024b

Differences in C Code Generation for Switch blocks between Matlab 2021b and Matlab 2024b

PuTI / 2025-07-04
Differences in C Code Generation for Switch blocks between Matlab 2021b and Matlab 2024b
Matlab News

Hi, recently Matlab 2024b was rolled out in our company, and when I startet a new project based on an old project created with Matlab 2021b, I noticed a strange difference in the generated C code for switch blocks:
I use a switch block to set an uint32 output to 1 of 2 different values based on a boolean input.
In Matlab 2021b, I always get an if-else in the code.
In Matlab 2024b, but only if the 2 values are 1 and 0, I get the ternary conditional operator (also called "question mark operator") instead (for other values than 1 and 0, I still get if-else though). Unfortunately, this operator is not permitted according to our company coding standard.
Is there a way to make the embedded coder also always produce if-else in Matlab 2024b? I have not found any settings and also not found any mention of this change in the release notes.
Background info: When using datatype conversion from boolean to uint32, Matlab 2021b also produces the ternary conditional operator. That’s why I used the switch blocks to avoid this construct. Now this exact workaround does not work anymore due to the different behaviour. So alternatively, if there is an easy way to tell the datatype conversion to use a simple cast (after all, the values can only be 1 or 0) instead of either ternary conditional operator or if-else, that would also solve my problem.Hi, recently Matlab 2024b was rolled out in our company, and when I startet a new project based on an old project created with Matlab 2021b, I noticed a strange difference in the generated C code for switch blocks:
I use a switch block to set an uint32 output to 1 of 2 different values based on a boolean input.
In Matlab 2021b, I always get an if-else in the code.
In Matlab 2024b, but only if the 2 values are 1 and 0, I get the ternary conditional operator (also called "question mark operator") instead (for other values than 1 and 0, I still get if-else though). Unfortunately, this operator is not permitted according to our company coding standard.
Is there a way to make the embedded coder also always produce if-else in Matlab 2024b? I have not found any settings and also not found any mention of this change in the release notes.
Background info: When using datatype conversion from boolean to uint32, Matlab 2021b also produces the ternary conditional operator. That’s why I used the switch blocks to avoid this construct. Now this exact workaround does not work anymore due to the different behaviour. So alternatively, if there is an easy way to tell the datatype conversion to use a simple cast (after all, the values can only be 1 or 0) instead of either ternary conditional operator or if-else, that would also solve my problem. Hi, recently Matlab 2024b was rolled out in our company, and when I startet a new project based on an old project created with Matlab 2021b, I noticed a strange difference in the generated C code for switch blocks:
I use a switch block to set an uint32 output to 1 of 2 different values based on a boolean input.
In Matlab 2021b, I always get an if-else in the code.
In Matlab 2024b, but only if the 2 values are 1 and 0, I get the ternary conditional operator (also called "question mark operator") instead (for other values than 1 and 0, I still get if-else though). Unfortunately, this operator is not permitted according to our company coding standard.
Is there a way to make the embedded coder also always produce if-else in Matlab 2024b? I have not found any settings and also not found any mention of this change in the release notes.
Background info: When using datatype conversion from boolean to uint32, Matlab 2021b also produces the ternary conditional operator. That’s why I used the switch blocks to avoid this construct. Now this exact workaround does not work anymore due to the different behaviour. So alternatively, if there is an easy way to tell the datatype conversion to use a simple cast (after all, the values can only be 1 or 0) instead of either ternary conditional operator or if-else, that would also solve my problem. switch block embedded coder MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Random Forest with paired observations: how to maintain subject separation
2025-07-08

Random Forest with paired observations: how to maintain subject separation

Why is uiaxes small by default in a uifigure?
2025-07-08

Why is uiaxes small by default in a uifigure?

For the trainNetwork function, progress plots for training are not closing, except if done manually. How do I close it? I have tried close all, close force, close(fig), & more
2025-07-08

For the trainNetwork function, progress plots for training are not closing, except if done manually. How do I close it? I have tried close all, close force, close(fig), & more

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term