I have a problem that I thought I knew how I can fix, but apparently I failed ..
I got a .mat file that I created. It has two columns and 25 rows of numbers. I would like to do a loop to get each value in the first column and put it in the X value, and the second column in the Y value. I then need to plot the points on the graph.
I know how to do the loop, and the plotting .. but I failed to extract the data and put them in X and Y values.
This is my trial code:
load figureinfo.mat
for K=1:25
x=X(:,K) ~~ I remember that the code looks something like that to extract ..
y=Y(:,K)
plot(x,y,'o')
hold on
end
How do I get the data and put it in X and Y?
In addition, where is “ROWS” in (:,b)? b=Columns, but where do I put the rows?
Try the following:
Or more simply,
If you don’t know the name of the matrix in your
.matfile, I recommend:which will show the the name, size, and datatype of whatever you just loaded.
If you really want to extract the data in a loop, you have two options:
or (faster because it doesn’t keep reallocating
XandY)