Hi Tabassum,
The error you are encountering comes from the fact the SVM model is trained on two features i.e. two columns of meas data:
X = meas(:,3:4);
; hence it expects the same number of features (dimension of xGrid) when predict function is called.
The latter part of the code computes the prediction of the trained SVM model on a grid covering the 2D feature space of petal length and width, and then determines the winning class for each point by selecting the model with the highest score, probably for visualising the decision boundary.
If you want to use all of the features, the model needs to be trained on all columns of X.
X = meas;
You could create a 4D grid and compute scores on all points in the 4D feature space, but you wont be able to visualize the decision boundary on a plot. For creating a 4D grid, you can use the ndgrid function. Refer to the following link: https://www.mathworks.com/help/matlab/ref/ndgrid.html