Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How do i make a function that recognises the number on the input.

1 visualizzazione (ultimi 30 giorni)
So i´ve been struggling to make this code. I´m trying to make a function that recognises the number given in an input so that it gives as a return an imshow of a matrix made out of ones and zeros that represents the number given as if it was a numeric display.
I´ve tried it by making a really long code with multiple if´s; kinda like this:
if input= number:
return imshow(NumberMatrix)
But the thing is that i want to make a shorter code because i have to make it for all the numbers with one or two digits.
  1 Commento
Stephen23
Stephen23 il 4 Ott 2019
Modificato: Stephen23 il 4 Ott 2019
I doubt that writing lots of elseif cases would be a good solution.
One simple MATLAB solution would be to define one numeric array (or perhaps a cell array), which could be generated by hand or in a loop or from imported data or whatever. Then you can trivially use indexing to access the data.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by