MATLAB: Simple question about scatter/data plots

data plotsscatter plots

Say I have two scripts. The first one is called RideData. It contains four arrays that are called speed, distance, climb, and calories. Those are the four variables assigned to four arrays. The second script is the main one where I want to create a scatter/data plot. If I wanted to use the speed and distance arrays from the first script to plot in the second script, how would I call the first script in order to plot using those arrays?

Best Answer

Your best option is to change your RideData script into a function (see documentation about functions) and have that function return those arrays, something like that:
function [speed, distance, climb, calories] = RideData()
% enter your functionality here
end
then you simply call the function from your main script like that:
[speed, distance, climb, calories] = RideData();
% now you can plot your stuff