Stepper motor speed problem on Matlab

Hello everyone,

I have a question about steppermotor control on matlab. the code that I wrote on matlab works very slow and I need moch more faster for my project.

Stepper( nema 34)

Using these codes;

%%%%%%%%%%PUL = 11 from CWD 556 driver and using  +PUL, +DIR and +ENA
%%%%%%%%%%DIR = 10
%%%%%%%%%%ENA = 9
clear all;

global a;
a = arduino('com3');

writeDigitalPin(a, 9, 0);
writeDigitalPin(a, 10, 0); 

for i=1:1000

Note: When I run this code on arduino it works fine , but on matlab, the motor rotates 1 rev about 40 seconds.

For Matlab ;

using adio code from Matlab package.

It is totally impractical to send individual steps over a USB connection due to the inherent latency in the USB system.

You need an Arduino program that can make a motor move N steps at R speed and then your Matlab program can send appropriate values for N and R and let the Arduino get on with the job.

This is a particular example where an Arduino outshines a PC.