How do I use multiple matrices?
显示 更早的评论
I have an array of temperatures that start from 0 and go to 50. The array goes in increments of 10. So I have declared,
T=0:10:50
I have another array which are the relative humidity’s that goes from 10 to 100. I have this set to go in increments of 10.
RH=10:10:100
If I want to find the dew point at each temperature, I have to consider each of the following relative humidity’s too. How do I incorporate each element of the temperature array with each element of the relative humidity array in the equation? Dewpoint =
DewpointT= T -(100-RH/5)
. I thought I would use meshgrid, but I was getting negative values.
回答(1 个)
DewpointT= T(:) - (100-RH/5)
3 个评论
Monica Padykula
2021-4-1
That is correct, given the formula you stated. When T is 0 and RH is 10:
T = 0;
RH = 10;
D = T - (100-RH/5)
Even if you meant to divide (100-RH) by 5 rather than subtracting RH/5 from 100, it's still negative. In this case you're still subtracting something positive from 0 and that's going to give you a negative value.
D = T - (100-RH)/5
Matt J
2021-4-1
If you need to keep only non-negative values, do
DewpointT(DewpointT<0)=[];
or
DewpointT(DewpointT<0)=nan;
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!