Complete the code to check if variable a is equal to 10.
result = (a [1] 10);
In MATLAB, == is used to compare if two values are equal.
Complete the code to check if variable x is greater than 5.
if x [1] 5 disp('x is greater than 5'); end
The operator > checks if the left value is greater than the right value.
Fix the error in the code to check if y is not equal to 0.
if y [1] 0 disp('y is not zero'); end
The operator ~= means 'not equal' in MATLAB.
Fill both blanks to create a logical expression that checks if z is between 1 and 10 (inclusive).
if (z [1] 1) && (z [2] 10) disp('z is between 1 and 10'); end
Use >= to check if z is at least 1, and <= to check if z is at most 10.
Fill all three blanks to create a dictionary (struct) comprehension that stores whether each number in nums is less than 5.
result = struct(); for i = 1:length(nums) result.[1] = (nums(i) [2] 5); end keys = fieldnames(result); for k = 1:length(keys) disp([keys{k} ': ' num2str(result.(keys{k}))]); end
We use num2str(nums(i)) as the field name, check if nums(i) < 5, and convert i to string for display.
