This is the sample code:
TorqueCurve = [0 400 800 1200 1600 2000 2400];
TorqueCurve(1,2:6);
I don’t currently have a copy of MATLAB, so I can’t test this myself, but I would like to know:
Am I correct in my assumption that the first declaration creates a single dimensioned variable with the contents 0, 400, 800, etc.?
What exactly, in prose (English), is the meaning of the second line? What is it accessing, and how?
Thanks in advance!
The first line declares an array of size 1-by-7 containing
0,400, etc.The second line extracts, from row 1, columns 2 through 6, and is equivalent to writing
TorqueCurve(1,[2 3 4 5 6]).The result, which you’ll see printed to the command window if you evaluate that line without semicolon at the end, is
400800etc., since Matlab indexing is 1-based.