Problem with dash and number of values

1 次查看(过去 30 天)
I was doing this script, in which I should have 72 answers (24 answers with each value of d), but I only have 24 value, hence, my script is only considering one of my values of d. Also, in line 32 it says the dash is incorrect, please help me with that. The script is as follows:
phi = 53;
d = 100:100:365;
for i = 1:1:length(d)
delta(i) = -23.45 * cosd((360/365) * (d(i)+10));
end
h = 1/24:1/24:1;
for i = 1:1:length(d)
for j = 1:1:length(h)
h_a(j) = 360 * (h(j)-0.5);
alpha(j) = asind(((sind(phi) * sind(delta(i))) + (cosd(phi) * cosd(delta(i)) * cosd(h_a(j)))));
theta(j) = 90 - alpha(j);
end
if h <= 0.5
beta(j) = -acosd((((sind(delta(i)) * cosd(phi)) - (cosd(h_a(j)) * cosd(delta(i)) * sind(phi)))/sind(theta)));
else
beta(j) = acosd((((sind(delta(i)) * cosd(phi)) - (cosd(h_a(j)) * cosd(delta(i)) * sind(phi))))/sind(theta));
end
end
  1 个评论
Sarah Kneer
Sarah Kneer 2020-12-23
Sorry the line that I mentioned is not 32, it's the line with beta(j) = acosd...

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-12-23
theta is a vector so /sind(theta) is attempting to do a Matrix Right Division operation, which fails because the left side is not the correct size for mrdivide.
In order for that code to work, theta would have to be a column vector, and the left side of the / would also have to be a column vector, so that the / mrdivide operation could return a scalar (essentially a least-squared fit.)
... Or you could index theta so that you have scalar divided by scalar.
  3 个评论
Sarah Kneer
Sarah Kneer 2020-12-23
So I solved that line but I’m still only getting 24 answers, any idea of how I can get all the answers?
Walter Roberson
Walter Roberson 2020-12-31
if h <= 0.5
beta(i,j) = -acosd((((sind(delta(i)) * cosd(phi)) - (cosd(h_a(j)) * cosd(delta(i)) * sind(phi)))/sind(theta)));
else
beta(i,j) = acosd((((sind(delta(i)) * cosd(phi)) - (cosd(h_a(j)) * cosd(delta(i)) * sind(phi))))/sind(theta));
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by