Simple question about scatter/data plots

14 visualizzazioni (ultimi 30 giorni)
Mikey Pham
Mikey Pham il 6 Dic 2018
Risposto: TADA il 6 Dic 2018
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?

Risposta accettata

TADA
TADA il 6 Dic 2018
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

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by