What is the meaning of this line?

2 views (last 30 days)
Isuru
Isuru on 14 Apr 2014
Answered: Walter Roberson on 14 Apr 2014
Hi,
I was wondering what this line meant?
Xe_dead = RunProcessModel(Xe_dead,speed_dead,GyroZ_dead,Dt);
Xe_dead_buffer = [Xe_dead_buffer Xe_dead(1:2)];
So the first line is an array of 3x1 values. I'm wondering what the syntax of the second line is?
Is it basically adding to the Xe_dead_buffer? I purely want to know the exact meaning of the second line.

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2014
We cannot tell what the first line is for sure. It might be a call to a function named RunProcessModel, passing in the four values Xe_dead, speed_dead, Gyroz_dead, and Dt. Or it might be accessing a 4-dimensional array.
If it is an array then in order for it to be 3 x 1 result, Xe_dead would have to be a vector of 3 values, and the other variables would have to be scalars. For a 1 x 3 result, speed_dead would have to be a vector of 3 values and the other variables would have to be scalars. Unless, that is, some of the variables are logical vectors.
The second line takes the first two values that were stored in Xe_dead from the previous call, and does a horizontal concatenation of them on the end of Xe_dead_buffer, storing the result into Xe_dead_buffer. We cannot tell from the code whether Xe_dead is a row vector or a column vector or something else. If it is a row vector then in order for the horizontal concatenation to work, Xe_dead_buffer would have to be empty or else it would have to be a row vector already. If Xe_dead is any other (non-empty) shape then taking the first two elements will give a column vector result, and in order for the horizontal concatenation to work, Xe_dead_buffer would have to be empty or else it would have to be column vector with two rows or a 2D array with two rows.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!