|
"jeremy " <rower15@excite.com> wrote in message
<g664cp$mjd$1@fred.mathworks.com>...
> I am a rather new user to the MATLAB world and I am having
> some difficulty figuring this out.
>
> I have a mat-file that contains an array of 2 cols and 14
> rows. When this mat-file is loaded, it produces a variable
> called "hc_actual" which is a 14x2 double.
>
> Here's what I want to do...
>
> Add code to my M-file that will allow me to enter a new X,Y
> pair at the command window prompt, append that pair to the
> first empty row in the "hc_actual" array, and then save the
> mat-file. Then the M-file can continue on without
> interaction and produce all my plots, etc.
>
> Could someone help me come up with the code that allows me
> to append the X,Y pair to the array?
>
> Thanks!
>
You can index past the end of the array and Matlab will
dynamically resize it for you:
load hc_actual.mat
hc_actual = rand([14 2]);
new_value = [2.3123 4.6631];
hc_actual(end+1, :) = new_value; % appends to end of
hc_actual - now a 15x2 matrix
save hc_actual
Rod
--
http://iheartmatlab.blogspot.com
|