Calculating motor rpm with MATLAB GUI

Hi , I want to control speed of my motor with motor speed sensor. So that i want to calculate rpm of my motor. i have 2 questions in this subject

1- where should i write reading code for sensor. I mean i don't want to read rpm when i press a button. i want to run it always. which part of MATLAB gui execute codes repeatedly. i dindt understand this part

2- what is the way of counting pulses from my sensor.

thank you

Please read and follow this link: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Helpers will not design Your entire project.
Start learning Arduinos and programming using the suitable simple example codes within the IDE.

Maybe I can't explain myself. I did simple examples and have enough knowledge about this project. But I could understand next step. I can drive motor with Matlab gui, I can change its speed , but can't do pulse counting right know. I ve read lots of documents and watch videos. In the end i m asking pros to draw path to me. Probably people can understand where I m struggling and I expect them to to show me right path. Am I wrong ?

Make a separate, little test and learn code exploring pulse counting. Then incorporate the pulse counting function in the existing code.

Thank you for ur help. But Actually my main problem is not pulse counting. I asked it to learn preferred way in Matlab. In Arduino ide it s not confusing ( interrupt) but in Matlab GUI it is possible to use interrupts? I am asking this in 2nd question. But still i don't know where should I do it in Matlab GUI because it doesn't have loop function. Or any saperate function. And I get confused in here

This is an Arduino forum, not a Matlab forum.
Are You sure there are not better alternatives?

Haha, @Railroader said it!

You are only wrong to espect anyone to know about MAtlab and an odd corner of it prolly at that.

a7

Probably there is. With Arduino ide I can do it easily. But I need to use Matlab GUI. So im still searching

I suggest You read relevant documentation for Matlab to see if they have a solution, or suggestions bringing You closer to a solution.

İ finally finished project. Anyone interested can watch my video... Thank you