MATLAB & GNU Octave Module 1
Start here: MATLAB, Octave and a working setup interview questions
Interview questions on “Start here: MATLAB, Octave and a working setup”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher
What is the difference between MATLAB and GNU Octave?
Answered in the lesson MATLAB and GNU Octave: one language, two tools
-
Fresher
How do you find out which Octave version and which BLAS a computer uses?
Answered in the lesson Install GNU Octave 11.3 and run your first script
-
Fresher
What does a semicolon at the end of a line do, and what is ans?
Answered in the lesson Command window basics: variables, ans and display
-
Fresher
In what order does Octave look for a function when a script uses a name?
Answered in the lesson Scripts, the current folder and the search path
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Fresher to mid
You set up the computing for a first-year engineering course of 120 students: Octave on their laptops, a campus MATLAB licence, or MATLAB Online (basic). Which do you choose, and what do you check before deciding?
- What it tests
- Choosing from the course's real needs (Simulink, toolboxes, run length, network, licences) rather than habit, and testing the choice on the course's own scripts.
- First step
- List what the scripts and assignments use: Simulink, toolbox functions, MATLAB-only syntax, long runs, labs without a network. Then run every script in Octave 11.3 and in MATLAB Online (basic) and note what fails or hits a limit.
- Follow-ups
-
- Ten of the course's scripts call a toolbox function. What changes?
- Half the students have no reliable internet at home. Does that change your choice?
- How do you make sure graded results are the same whichever program a student uses?
From the lesson MATLAB and GNU Octave: one language, two tools
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your research group has 40 MATLAB scripts and must run them on new laptops that have only GNU Octave. How do you find what breaks, fix it, and keep the scripts working in both programs afterwards?
- What it tests
- Planning a portability audit: running everything, sorting failures into missing functions, Octave-only syntax and silent differences, and keeping one tested shared version.
- First step
- Run every script in Octave on its real data and record errors, warnings and results. Then compare the key results with MATLAB's numbers within a tolerance, because silent differences such as Name=value calls raise no error.
- Follow-ups
-
- A script runs in Octave but gives a different number. Where do you look first?
- Three scripts use string arrays and tables. What are your options?
- How do you stop new Octave-only or MATLAB-only code from creeping in?
From the lesson MATLAB and GNU Octave: one language, two tools
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A continuous-integration job runs your checks with octave-cli --eval "run_checks" | tee log.txt, and it passed although one check printed an error. What went wrong, and how do you make a failing check fail the job?
- What it tests
- Knowing that jobs decide by exit statuses, how a shell pipeline reports its status, and how checks must raise errors or exit with a non-zero status.
- First step
- Follow the status from the failing check to the job's last command. Run the Octave command alone and print its status, then run the whole pipeline and print its status, and compare the two numbers.
- Follow-ups
-
- How do you prove that the fixed job can fail?
- The job now fails, but nobody can see which check failed. What do you add?
- Why not just search the log for the word error?
From the lesson Install GNU Octave 11.3 and run your first script
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
The same script prints 1.130973355292325e-04 on your laptop and 1.1310e-04 on a classmate's, and a third laptop differs in the last digit of a long calculation. Explain each difference and how you make the outputs comparable.
- What it tests
- Telling a display difference from a computed one, finding startup files, comparing versions and libraries, and checking values with a tolerance.
- First step
- Separate display from value. The first two show the same number with 16 and 5 significant digits, which points to a startup file setting format long; run the script with --no-init-all and --init-trace to confirm.
- Follow-ups
-
- Which tolerance would you choose for comparing the results?
- The two outputs differ in the fifth digit. Is that still a display question?
- How do you stop startup files causing this again?
From the lesson Install GNU Octave 11.3 and run your first script
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Fresher to mid
A colleague's script stops with "error: sum(6): out of bound 1 (dimensions are 1x1)". The same lines worked yesterday. How do you find the cause, fix it, and keep it from coming back?
- What it tests
- Reading an Octave error message, knowing that variables hide functions, using which and exist to confirm it, and fixing the cause rather than the symptom.
- First step
- Read the message as Octave does: sum(6) was treated as indexing into something with one element, so the name sum is probably a variable. Check with which sum and exist('sum') in that session.
- Follow-ups
-
- The script is 300 lines long. How do you find where sum was assigned?
- Would MATLAB behave the same way?
- Could clear at the top of every script prevent this?
From the lesson Command window basics: variables, ans and display
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your course checks answers by comparing what each script prints with expected text made in MATLAB. A student's correct Octave answer fails. Explain why, and redesign the check so that correct answers pass in either program.
- What it tests
- Telling display from value, knowing how MATLAB and Octave lay numbers out, and designing value-based checks with tolerances, shapes and types.
- First step
- Compare the two outputs line by line and find what differs: blank lines, e-notation, scale factors or digits. If the numbers agree within rounding, the check is comparing displays, not answers.
- Follow-ups
-
- How do you pick the tolerance?
- A student prints the right number with disp instead of fprintf. Pass or fail?
- What about integer and logical results?
From the lesson Command window basics: variables, ans and display
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
A thesis script runs only when its own folder is the current folder; from anywhere else it cannot find its data. Your supervisor must run it from another folder on a cluster. How do you fix it, and how do you show the fix works?
- What it tests
- Knowing that relative paths depend on the current folder, building paths from the script's own location, and verifying a fix from more than one folder.
- First step
- Find every path the script opens or writes, such as load('data/loads.txt'), and note that each is relative to the current folder. Then decide where the script should take its bearings from: its own file, not the folder it was started in.
- Follow-ups
-
- Why not just put cd(fileparts(mfilename('fullpath'))) at the top?
- The cluster runs MATLAB with matlab -batch. Does the fix still hold?
- The data lives on a shared drive, not in the project. What changes?
From the lesson Scripts, the current folder and the search path
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
All MATLAB & GNU Octave interview questions · The MATLAB & GNU Octave track