Subscript indices must either be real positive integers or logicals
1 view (last 30 days)
Show older comments
Luis Meneses
on 25 Jul 2015
Commented: Luis Meneses
on 25 Jul 2015
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?
0 Comments
Accepted Answer
Azzi Abdelmalek
on 25 Jul 2015
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
0 Comments
More Answers (1)
Walter Roberson
on 25 Jul 2015
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
See Also
Categories
Find more on Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!