Subscript indices must either be real positive integers or logicals

조회 수: 2 (최근 30일)
x = tudo(:,2)
y = tudo(:,1)
w = tudo(:,3)
% normalize ships
min_x = min(x)
max_x = max(x)
norm_nav = (x - min_x)/(max_x - min_x)
tudo_norm(:,1) = norm_nav
% normalize hours
min_y = min(y)
max_y = max(y)
norm_horas = (y - min_y)/(max_y - min_y)
tudo_norm(:,2) = norm_horas
% normalize poff
min_w = min(w)
max_w = max(w)
norm_poff = (w - min_w)/(max_w - min_w)
tudo_norm(:,3) = norm_poff
% matrix A
A(:,1) = tudo_norm(:,3)
% matrix B
B(:,2) = norm_nav
B(:,3) = norm_horas
B(:,1) = 1
% matrix C
C = sym('C', [3 1])
% coefficients
transposed = B.'
BB = B.' * B
inverse = inv(B.' * B)
C = inv(B.' * B) * B.' * A
% W = D + AX + BY
T = C(1,1) + C(2,1) * norm_nav + C(3,1) * norm_horas
% RMSE
erro = T - norm_poff
sqerr = erro.^2
msqerro = mean(sqerr)
rmse = sqrt(msqerro)
% standard deviation
d_padrao = std(T)
% (SSE)
sse = sum(erro.^2)
xx = sse / (tamanho-3)
%-------------------------------------------
% TESTING
% Enter desired data
Navios = 3
Horas = 1
% New max an min?
if Navios > max(x) % max e min de x
max(x) = Navios
else
if Navios < min(x)
min(x) = Navios
end
end
if Horas > max(y) % max e min de y
max(y) = Horas
else
if Horas < min(y)
min(y) = Horas
end
end
% normalize new
navio = (Navios - min_x)/(max_x - min_x)
hora = (Horas - min_y)/(max_y - min_y)
max_navio = max(x)
max_hroas = max (y)
max_poff = max(w)
W = C(1,1) + C(2,1) * navio + C(3,1) * hora
% RMSE
erro = W - norm_poff
sqerr = erro.^2
msqerro = mean(sqerr)
rmse = sqrt(msqerro)
% (SSE)
sse = sum(erro.^2)
xx = sse / (tamanho-3)
POFF = (W*(max_w - min_w)) + min_w
Hello guys, I'm currently developing a code to the prediction of some data. However I have a problem. When intend to test the code, and enter the desired data, when I type the variable "Navios" = 1 the following error appears:
Subscript indices must either be real positive integers or logicals Error in ==> Modelo_2VAR at 90      if horas <min (y)
I do not understand why this error appears.
Someone help me?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 25일
There is a problem with the lines of code containing:
max(x) = Navios
min(x) = Navios
max and min are built-in functions, you can't use them as variables

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 7월 25일
if Navios > max_x % max e min de x
max_x = Navios
else
if Navios < min_x
min_x = Navios
end
end
if Horas > max_y % max e min de y
max_y = Horas
else
if Horas < min_y
min_y = Horas
end
end
  댓글 수: 1
Luis Meneses
Luis Meneses 2015년 7월 25일
Thank you.
But nevertheless, when I change the value of "Navio" from 0, 1, 2 and 3, the result does not change ... Why does it happen?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by