Fixing Incompatible Sizes while Calculating Absolute Vorticity
古いコメントを表示
I want to calculate the relative and absolute voriticity change using the following specifications. Then make a video out of it as it changes in height. However, I get errors with incompatible sizes and or dimensions. I do know whether or not the code for the video works...if anyone can help it would be much appreciated.
close all;
clear all;
clc;
curve = animatedline('LineWidth',2)
hold on;
grid on;
title('Temperant Absolute Vorticity Change');
partialu = 150; % in ms^-1
partialv = 120; % in ms^-1
partialx = (5:2100); %in meters
partialy = (9:4200); %in meters
T1 = (27:32);
T2 = (24:21);
dT = T2-T1;
dz = (30:168); % change in height
lapserate = dT./dz;
omega = 7.29*10^-5;
phi = 35; % change in latitude
dt = 0:60; % change in time in seconds
planetaryvort = 2*omega*sin(phi);
for i = 1:length(partialx)
for j = 1:length(partialy)
for t = 1:length(dt)
relativevort = partialv./partialx - partialu./partialy;
absolutvore = lapserate*(relativevort+planetaryvort)./dt;
F(i) = getframe(gca);
pause(0.01);
delete(head);
end
end
end
video = VideoWriter('Temperant Absolute Vorticity Change','Uncompressed AVI');
open(video)
writeVideo(video,F)
7 件のコメント
T2 is empty, so T2 - T1 is not compatible for subtraction.
After correcting this, you should correct for dT./dZ as well.
T1 = (27:32);
T2 = (24:21);
size(T1)
size(T2)
dT = T2-T1;
Jonathon Klepatzki
2023 年 12 月 11 日
Star Strider
2023 年 12 月 11 日
It might be beter to define a specific constant value for the various vectors and use that constant value with the linspace function to define the vector lengths (the third argument) so that they are all compatible in that respect. Since you are not using their values for indices (only their lengths), that should work.
The VideoWriter and related calls look correct, although it should probably conclude with a close call.
Jonathon Klepatzki
2023 年 12 月 11 日
Star Strider
2023 年 12 月 11 日
My pleasure!
Did everything else work after that?
Jonathon Klepatzki
2023 年 12 月 12 日
Avni Agrawal
2023 年 12 月 21 日
Hi Jonathon, can you share the updated code after the error fixes?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!