create a script that makes a x y graph. every time that i run the script i want to add new defined x y points in matlab

You can define your x and y values in vectors and then use the plot function to create the graph. Here's an example:

main.m
% Define x and y values
x = [1, 2, 3, 4];
y = [5, 3, 8, 4];

% Plot graph
plot(x, y)

% Add labels and title
xlabel('X values')
ylabel('Y values')
title('My Graph')
165 chars
12 lines

Now if you want to add new points every time you run the script, you can define your x and y vectors as empty and then use the input function to get the new values from the user. Here's the modified script:

main.m
% Define empty x and y vectors
x = [];
y = [];

% Get new x and y values from user
new_x = input('Enter x value: ');
new_y = input('Enter y value: ');

% Add new values to vectors
x(end+1) = new_x;
y(end+1) = new_y;

% Plot graph with all points
plot(x,y)

% Add labels and title
xlabel('X values')
ylabel('Y values')
title('My Graph')
336 chars
20 lines

Now every time you run the script, you can add new x and y points to the graph. Just be careful not to overwrite your original x and y values!

related categories

gistlibby LogSnag