Error message with arrays

13 次查看(过去 30 天)
Iver Brekken
Iver Brekken 2022-1-26
clear all
clc
close all
h = [2:20:220];
t_a = 293;
t_s = [];
q_flux = 800;
n = length(h);
for i = 1:n
t_s = q_flux./h+t_a;
y(i) = t_s;
i = i+1;
end
plot(h,y)
When running this i obtain the following error message:
Unable to perform assignment because the indices on the left side are not compatible with the size of
the right side.
Error in a2 (line 13)
y(i) = t_s;
what can i do different?

回答(1 个)

Alan Stevens
Alan Stevens 2022-1-26
You only need
h = [2:20:220];
t_a = 293;
q_flux = 800;
n = length(h);
y = q_flux./h+t_a;
i = i+1;
plot(h,y)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by