How to create a vector with elemts being the outputs of a function

조회 수: 1 (최근 30일)
Hello, we are given the ready function 'floris' which gives out power and speed at a specific location. Speed output is a numeric value. I want to create a vector (or just a set of values) named 'speeds' that has as elements, all the different speeds for all the location. My final purpose is to plot x-location vs speed.
To take it to the next level, I would like to be able to do simultaneously the same for y location. If I could do a 3d plot of [x, y] location that gives the speed output would be ideal. Have no idea how to do this though. Height stays fixed at 0.3m. x has to go from 10m to 14.16m and y from -0.54m to +0.54m.
Any help would be much appreciated and thank you in advance
for x=10:0.02:14.160
location = [x 0 0.3];
[power,speed]=floris(wind_speed,density,wind_direction,turbine_centre,yaw_angle,diameter,powercurve,location);
speeds(1,x)=speed
end

채택된 답변

Matt J
Matt J 2021년 4월 29일
편집: Matt J 2021년 4월 29일
One way,
fun=@(x) floris(wind_speed,density,wind_direction,...
turbine_centre,yaw_angle,diameter,powercurve,[x 0 0.3]);
[power,speed]=arrayfun(fun, 10:0.02:14.160);
  댓글 수: 2
Grigorios Chatziandreou
Grigorios Chatziandreou 2021년 4월 29일
hey, i tried it but did not seem to work
Matt J
Matt J 2021년 4월 29일
Here is a simpler, made-up example, just to illustrate what should happen:
fun=@(x) deal( sum([x,0,0.3]) , mean([x,0,0.3])) ;
[power,speed]=arrayfun(fun, 10:0.02:14.160);
whos power speed
Name Size Bytes Class Attributes power 1x209 1672 double speed 1x209 1672 double

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by