I am trying to run the following code:
function [wind_directions,wind_speeds, de, relative_wind, ascending, wind_effectiveness] = we(absolute_yaw,wind_file,wind_row,pitch_angle)%% James Kempton 11/06/2019
%% A function for calculating wind effectiveness
% load wind data
load(wind_file)wind_directions=[wind.location_1(:,1),wind.location_2(:,1),... wind.location_3(:,1),wind.location_4(:,1),... wind.location_5(:,1),wind.location_6(:,1)];wind_speeds=[wind.location_1(:,2),wind.location_2(:,2),... wind.location_3(:,2),wind.location_4(:,2),... wind.location_5(:,2),wind.location_6(:,2)];% find difference in wind vector direction and heading vector direction
theta_diff=[absolute_yaw-wind.location_1(wind_row,1),... absolute_yaw-wind.location_2(wind_row,1),... absolute_yaw-wind.location_3(wind_row,1),... absolute_yaw-wind.location_4(wind_row,1),... absolute_yaw-wind.location_5(wind_row,1),... absolute_yaw-wind.location_6(wind_row,1)];% calculate directional effectiveness
de=abs(cosd(theta_diff));% assign headwind value 1
relative_wind=abs(theta_diff)>=90&abs(theta_diff)<=270;relative_wind=double(relative_wind);% assign tailwind value -1
relative_wind(relative_wind==0)=-1;% assign ascent value 1
ascending=pitch_angle>0;ascending=double(ascending);% assign descent value -1
ascending(ascending==0)=-1;% you know have 3 vectors, two a series of positive or negative ones and
% which together capture the phasing of the flight, and a third cpaturing
% the directional effectiveness. Together they are the wind effectiveness.
wind_effectiveness=ascending.*relative_wind.*de;
I receive this error message:
The class wind has no Constant property or Static method named 'location_1'.
Error in we (line 21)
theta_diff=[absolute_yaw-wind.location_1(wind_row,1),…
This is surprising given I can use wind.location_x up to line 21. Playing around I find that the function only allows wind.location_x if the index is (:,col). As soon as I try to specify specific rows the above error message arises.
I have attached the wind.mat table which is my wind_file above. Why does the above issue occur? How do I resolve it?
Thank you, James
Best Answer