How do I used the program stickplot.m

8 次查看(过去 30 天)
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;

采纳的回答

Geoff Hayes
Geoff Hayes 2016-1-6
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by