Error message with arrays

조회 수: 1 (최근 30일)
Iver Brekken
Iver Brekken 2022년 1월 26일
답변: Alan Stevens 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에서 Target & Compiler에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by