필터 지우기
필터 지우기

Fixing Incompatible Sizes while Calculating Absolute Vorticity

조회 수: 1 (최근 30일)
Jonathon Klepatzki
Jonathon Klepatzki 2023년 12월 11일
답변: Nipun 2023년 12월 26일
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
Jonathon Klepatzki
Jonathon Klepatzki 2023년 12월 12일
Sadly no. After I clicked run, it would not bring up the video. I think maybe perhaps the size maybe the problem with it.
Avni Agrawal
Avni Agrawal 2023년 12월 21일
Hi Jonathon, can you share the updated code after the error fixes?

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

채택된 답변

Nipun
Nipun 2023년 12월 26일
Hi Jonathon,
I understand that you are trying to calculate the relative and absolute vorticity change using the specifications as dictated by your code, but you are getting a "dimension incompatible" error.
On analyzing your code, I have found that "dT" can not be evaluated since "T1" and "T2" have different sizes.
T2 = 24:21
% T2 has size 1,0 since the end point is smaller than starting point
% to get a series 24 23 22 21, do:
T2 = 24:-1:21
However, the error will still persist since "T1" has size "1 x 6" and "T2" (after correction) has size "1 x 4"
MATLAB does not support subtraction in vectors of different lengths.
I recommend either fixing your declaration of "T1" and "T2" to make sure they have the same dimensions. Or you, may consider padding "T2" with zeros ro support the subtraction operation.
Hope this helps.
Regards,
Nipun

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by