create a matfile where a diagramm is build in matlab

To create a matfile containing a plot in MATLAB, follow the steps below:

  1. Generate the data for the plot you want to save to a file.

  2. Create a figure and plot the data onto it.

x = linspace(0, 2*pi, 50);
y = sin(x);
figure;
plot(x, y, 'b--o');
xlabel('x');
ylabel('y');
title('Sine function');
117 chars
8 lines
  1. Save the figure to a matfile.
save('plot.mat', 'x', 'y');
28 chars
2 lines

That's it! You have now saved the data used to create the plot to a matfile.

Note that the actual plot is not saved in the matfile. Only the data used to create it is saved. To recreate the plot, you will need to load the data from the matfile and create the figure and plot again using the plot command.

load('plot.mat', 'x', 'y');
figure;
plot(x, y, 'b--o');
xlabel('x');
ylabel('y');
title('Sine function');
106 chars
7 lines

This will recreate the original plot from the saved data.

related categories

gistlibby LogSnag