Find the difference between two numbers in an array and create a new array

조회 수: 10 (최근 30일)
Hello, I am working on a meteoroogy project to calculate mean periods of buoyancy oscillation. Rather than do everything by hand, I figured it would be easier to throw them in matlab and have it calculate it. Right now, I'm at a point where I have calculated theta values in an array (11,1). For the equation I am using, I need to find the difference between theta values in order to use that number for my equation. (g/theta * differnece in Theta/difference in height)
All of these are in their own arrays. At this point, I need help figureing out what commands to use to have it figure out the difference between each of the theta values (and height, but I'm assuming I will end up just using the same code). I have attached the working code I have used to get each value so far.
One thing that can throw a wrench into my plans... there are two data sets that I have combined into one with a blank box in between them in order to split them apart. So I'll have to account for that, which will be a problem on its own. Thank you for your help!
Table = readtable('file.xlsx');
pres = Table(: , 1);
hght = Table(: , 2);
temp = Table(: , 3);
dwpt = Table(: , 4);
rh = Table(: , 5);
mixr = Table(: , 6);
Rdcpdry = .286;
thing = Rdcpdry;
tp1 = (1000 ./ pres{: , 1}) .^thing;
theta = (temp{: , 1}) .* tp1;

채택된 답변

Sargondjani
Sargondjani 2021년 11월 9일
d_theta=diff(theta);
  댓글 수: 2
Ian Mason
Ian Mason 2021년 11월 10일
That was great! Thank you! Now I am running into issues calculing the d_hght. I'm trying to use the code d_hght = diff(hght);
But, I'm getting this error... Check for missing argument or incorrect argument data type in call to function 'diff'.
Ian Mason
Ian Mason 2021년 11월 10일
Figured it out. I forgot to put the call to the table in brackets.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by