필터 지우기
필터 지우기

fluctuations with specified mean velocity and amplitude

조회 수: 2 (최근 30일)
Alina Abdikadyr
Alina Abdikadyr 2023년 2월 26일
댓글: Walter Roberson 2023년 2월 27일
Hello everyone!
Could you please help me with a code. How could I plot the random fluctuation plots with specified mean velocity and amplitude of fluctiations
My code is:
clc
clear
N=100;
t=(1:1:N);
for i=1:N;
v(i)=randn(1,1);
end
V(1:N)=mean(v)
plot(t,v,'-*')
hold on
plot(t,V)
title('Reynolds Decomposition of Velocity')
xlabel('Time')
ylabel('Mean+Fluctuating Velocity v')
grid on
  댓글 수: 2
Image Analyst
Image Analyst 2023년 2월 26일
Not sure I understand. It looks like you ARE plotting velocity versus time, so what's the problem?
Alina Abdikadyr
Alina Abdikadyr 2023년 2월 26일
so, if in the begining i would have as the inpute the fluctuatuins and specific amplitude, how to generate the random velocities with specified fluctuations and amplitude

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

답변 (2개)

VBBV
VBBV 2023년 2월 26일
plot(t,v+V,'-*')
hold on
plot(t,V)
Do you mean the above ?

Walter Roberson
Walter Roberson 2023년 2월 26일
You say working with velocity, which is a vector, but you only have a single coordinate.
If you want your velocity functuations to have a specified amplitude then that means that you need to use at least two dimensions for your points, and you need to generate a vector at each location, with random angle(s) but particular amplitude. For example,
ang = rand(1,N) * 2 * pi;
amp = AppropriateConstant
deltax = sin(ang) .* amp;
deltay = cos(ang) .* amp;
x = cumsum([x0, deltax]);
y = cumsum([y0, deltay]);
If you needed a particular mean velocity then instead of using rand() you would have to use a beta distribution over 0 to 2*pi, which had been tuned so that the mean of the distribution was the desired mean.
  댓글 수: 6
Alina Abdikadyr
Alina Abdikadyr 2023년 2월 27일
sorry, the error appeared:
Error using plot3
Vectors must be the same length.
Error in untitled (line 10)
plot3(t, x, y)
Walter Roberson
Walter Roberson 2023년 2월 27일
t = (0:N) / SamplingFrequency;
for the case where you generate N points after the starting point.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by