Question
This is an example from a textbook that I'm working with as a beginner. Why would this have semi colons after the 8.99 and -1.50? updatePriceTable([19.99, 9.99; 14.99, 8.99;], [-1.00; -1.50;], 1)
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 23, 2026
Suppose that you are writing out several rows of value using code. You write out the initial [ and you start writing values. You reach the end of the first row. You now have three possible strategies:
- Test to see if you are at the last row, and if not then put in ; -- and after you leave the loop, put in the ] and continue with whatever you were doing; OR
- write out ; anyhow -- and after you leave the loop, put in the ] and continue on with whatever you were doing; OR
- create all of the row-by-row strings in memory, and after you are doing, strjoin() them with ; (which will not put a semi-colon at the end); then put on the ] and write it all out to output, and then continue on
The first strategy requires a last-row test every iteration, which is difficult to vectorize unless you use hacks such as having an output variable that contains semi-colon for all rows except the last but is empty for the last one.
The third strategy requires that the output fits into memory
The second strategy can be vectorized. It's "cost" is that you end up with one extra semi-colon on output that is not strictly needed.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related semicolon Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →