How can I remove repeating values from the vector?
古いコメントを表示
Hi,
I've got a loop that simulates Simulink model, collects the data and plots everything on the graphs, here is simplified code:
for v = 4:3:26
air_velocity = v;
while abs(old_u - new_u) >= errortolerance % siumlate untill model converges
simOut = sim('TurbineWithVariablePitch_new_.slx',time);
umax = round(max(simOut.Velocity), 2);
old_u = new_u;
new_u = umax;
disp(['Current iteration: ',num2str(iteration), ' for time: ', num2str(time, '%10.5e') ])
if abs(old_u - new_u) <= errortolerance
cprintf('*blue',['Solution fully converged with the current error of ', num2str(abs(old_u - new_u))]);
cprintf('\n');
else
disp(['Solution did not converged with the current error of ', num2str(abs(old_u - new_u))])
end
if iteration >= maxiteration
cprintf('*red','Solution did not converged\n');
break
end
iteration = iteration +1;
time = time + timestep;
end
simulationtime = [0:0.01:2000];
a = round(simOut.AoA.signals.values);
n=max (numel(simulationtime)); %make the vectors the same size
u(end+1:n)=nan;
a(end+1:n)=nan;
AoAout = [AoAout , a]; %add to the results
SimulationTime = [SimulationTime , simulationtime'];
end
f4 = figure('Name','AoA vs Time');
plot(SimulationTime, AoAout, 'linewidth', 2);
ylabel('AoA (deg)');
xlabel('Time (s)');
The problem is, I'm getting repitetive values for AoA:

They are not always the same so unique command doesn't work... I've been stuck on this problem for a while. I'm fairly new to MATLAB and tring to achieve something similar to this:

6 件のコメント
Cris LaPierre
2020 年 3 月 22 日
編集済み: Cris LaPierre
2020 年 3 月 22 日
You are plotting AoA vs Time while the example you are trying to recreate is AoA vs Azimuth.
Mariusz Sledz
2020 年 3 月 22 日
Cris LaPierre
2020 年 3 月 22 日
I'll leave this as a comment instead of an answer since I'm not sure what to do next. However, it appears your data is cyclical with azimuth angle. Thoughts I have:
- Select a single 0-360 azimuth angle cycle to plot
- Average all the cycles, resulting in a single line. This will also hopefully remove the lines connecting the beginning to the end of each line.
Mariusz Sledz
2020 年 3 月 22 日
Mariusz Sledz
2020 年 3 月 24 日
Mariusz Sledz
2020 年 3 月 26 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
