For Knobs (continuous)
There are a few things wrong with your callback function. I've listed them in order of importance.
- The "Value" of your switch-case is numeric but your cases are character vectors so none of the cases will ever be chosen. Use a series of if-elseif conditionals. You could also use a switch-case with logical comparisons as in this answer.
- "Items" is not a property of a knob. Instead, use the "MajorTicks" property which expects a vector (not a cell array).
- In addition to MajorTicks, set the "Limits" propery to maximize the full range of your knob
- The "value" property expects a scalar, not a cell.
Here's how the callback should appear (showing 1 line, you can adapt the rests)>
if value >=1 && value <= 10
set(app.Knob,'MajorTicks',[1,2,3,4,5,6,7,8,9,10],'Limits',[1,10],'Value',5);
elseif
else
end
For "Discrete Knobs"
- The 'Items" property is expected to be a cell array of strings or chars. You can use num2str with strsplit to convert your numeric vector to a cell array of chars.
- The "value" property is expected to be a char array that belongs to the updated Items list.
Here's how the callback should appear (showing 1 line, again)
switch value
case '1-10'
set(app.Knob3,'Items',strsplit(num2str([1,2,3,4,5,6,7,8,9,10])),'Value','5');
Best Answer