Borrar filtros
Borrar filtros

How do I used the program stickplot.m

11 visualizaciones (últimos 30 días)
Jenny
Jenny el 6 de En. de 2016
Comentada: Jenny el 7 de En. de 2016
I have downloaded the stickplot.m program from WHOI.
The program 'feather plots' or 'stick plots' data with a scale (see attached 'stickplot.m' program). I have also attached the demo file ('stickdemo.m')
I do not know how to apply this program to my current data.
I have speed and direction and currents split into UV components (see attached 'stickplot data.csv' data set).
The code below is to read in the data.
All help would be greatly appreciated. Jenny
filename = 'D:\StickPlot data.csv';
delimiter = ';';
startRow = 10;
formatSpec = '%s%s%s%s%f%s%f%f%s%f%f%s%f%f%s%f%s%s%f%s%s%f%s%s%f%f%s%f%f%s%f%f%s%f%s%s%f%s%s%f%s%s%f%s%s%f%s%s%f%s%s%f%s%s%f%s%s%f%s%s%f%[^\n\r]';
% Open the text file.
fileID = fopen(filename,'r');
% Read columns of data according to format string.
textscan(fileID, '%[^\n\r]', startRow-1, 'ReturnOnError', false);
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'ReturnOnError', false);
% Close the text file.
fclose(fileID);
% Convert the contents of column with dates to serial date numbers using date format string (datenum).
dataArray{1} = datenum(dataArray{1}, 'mm/dd/yy HH:MM:SS');
% Allocate imported array to column variable names
Date5m = dataArray{:, 1};
Spd5m = dataArray{:, 7};
Dir5m = dataArray{:, 10};
vCurr5m = dataArray{:, 13};
uCurr5m = dataArray{:, 16};
% Clear temporary variables
clearvars filename delimiter startRow formatSpec fileID dataArray ans;

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 6 de En. de 2016
Jenny - the function signature for stickplot is
stickplot(tt,x,y,tlen,units,labels)
where tt is an array of time elements, x is the x-component of the vector, and y is the y-component of the vector. (The remaining inputs are optional so I think that we can ignore them for now.)
The data that you have extracted from your CSV file include the time, speed, direction, velocity in the north direction (so the y-direction), and velocity in the east direction (so the x-direction). So I think that it is these latter two arrays (along with the time data) that you can use to plot your data with stickplot. For example,
stickplot(Date5m,uCurr5m,vCurr5m);
Try the above and see what happens!
  1 comentario
Jenny
Jenny el 7 de En. de 2016
Who know what on earth I was doing yesterday but thank you !

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by