Hello sirona,
To add a new line to the existing .FIG file, you can follow these steps:
% Create some data
x1 = 0:0.1:10;
y1 = sin(x1);
figure;
plot(x1, y1, 'b-', 'LineWidth', 2);
title('Original Plot');
xlabel('X-axis');
ylabel('Y-axis');
saveas(gcf, 'example_figure.fig');
% Close the figure
close(gcf);
%%
% Step 1: Open the existing figure
fig = openfig('example_figure.fig', 'reuse'); % 'reuse' opens it in the same window
% Step 2: Get the current axes
ax = gca;
% Step 3: Add a new plot
hold(ax, 'on');
x_new = 1:10;
y_new = rand(1, 10);
plot(ax, x_new, y_new, 'r-', 'LineWidth', 2); % Add new plot
% Step 4: Save the updated figure if needed
savefig(fig, 'updated_figure.fig');
Kindly refer to the documetation by executing the following command in MATLAB Command Window to know more about 'openfig' function :
doc openfig