How can I use an excel file in the wind assessment demo?

6 次查看(过去 30 天)
I found a perfect example of wind data analysis. It’s found under WindAssessmentDA.m. They import their data from a text file. Can anyone tell me how to run the same script using data imported from an excel file instead?
%% Wind Resource Assessment Data Analysis % Harnessing wind energy for power generation is a potential option to meet % the demands of local energy markets. This demo analyzes wind data % measured on a meteorological observation tower located in Massachusetts. % There are two wind speed sensors at 49 m, two at 38 m, and one at 20 m. % There are wind direction sensors at 49 m, 38 m, and 20 m. The % temperature is recorded by a single sensor at 2 m. The mean, standard % deviation, minimum value, and maximum values of each sensor are logged % every ten minutes from 11 am on 5/25/2007 to 4:50 pm on 6/10/2008. % % Copyright 2009 - 2011 MathWorks, Inc. % % Written by Todd Schultz
% %% Import Data % Start the analysis by importing the data from source, which can include % Excel spreadsheets, text files, or even databases. MATLAB supports the % supports the importing and communication with a wide range of file % formats. In this example, we have a data file that contains 37 columns % of data. The first column is the date and the remaining columns are % numeric data. We'll import all of the data into MATLAB as a dataset % array directly from a file.
% An example of importing from a text file. % Use a format string to increase file i/o performance wind = dataset('file','winddata.txt','delimiter','\t', ... 'format',['%s' repmat(' %f',1,36)]); %was dataset
% An example of importing from a database. % Use the automatically generated MATLAB script from querybuilder to import % the data from the Access database and convert to dataset array. %wind = fcnImportDB; %wind = dataset(wind);
% Initialize storage of hub velocities, instantaneous kinetic energy flux, % and air density in the dataset wind.vhub = zeros(size(wind,1),1); wind.phub = zeros(size(wind,1),1); wind.rho = zeros(size(wind,1),1);
% Set unit property string for reminder of measurement units wind.Properties.Units = [{'date'} repmat({'m/s'},1,4*5) ... repmat({'deg'},1,4*3) ... repmat({'C'},1,4*1) ... 'm/s' 'W/m^2' 'kg/m^3'];
% Convert date to a Serial Date Number (1 = January 1, 0000 A.D.) wind.t = datenum(wind.date,'yyyy-mm-dd HH:MM:SS');
%% % Input Additional Analysis Information % % Additional information about proposed wind turbine hhub = 80; % hub height (m)
% Additional information about meteorological tower hv = [49 49 38 38 20]; % vector of heights for velocity (m) hvh = [hv hhub]; % vector of heights for velocity with hhub (m) hd = [49 38 20]; % vector of heights for direction (m) hT = 2; % vector of heights for temperature (m)
nobs = size(wind,1); % # of observations
% Air properties patm = 101e3; % atmospheric pressure (Pa) Rair = 287; % gas constant for air (J/kg K) % air density (kg/m^3) wind.rho = patm./(Rair*(wind.T3Avg+273.15));
clear patm Rair
  1 个评论
dpb
dpb 2023-2-26
Will depend on the content of the file as to whether it will match expectations of the script or not, but see <Spreadsheets> for comprehensive introduction to using MATLAB with Excel; probably readmatrix would be a good choice given what can be seen from the script using flat text file...

请先登录,再进行评论。

回答(1 个)

Animesh
Animesh 2023-4-4
Hi,
According to my understanding you are trying to import the same data with the help of excel. For this purpose, you need to first export the access table to an excel file with the help of inbuilt export tool in access.
After creating the excel file you can create use ‘readtable’ function in MATLAB to import the data and to convert the format to dataset with the help of ‘table2dataset’ function.
For more info: -

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by