Borrar filtros
Borrar filtros

Subscript indices must either be real positive integers or logicals.

2 visualizaciones (últimos 30 días)
Hanson Zhou
Hanson Zhou el 18 de Dic. de 2015
Respondida: Walter Roberson el 18 de Dic. de 2015
Hi All,
I have a function that runs perfectly in my main script. But after running the code when I publish a report, it gives me an error "Subscript indices must either be real positive integers or logicals." I'm confused, any help?
the function is
function [rf] = Spot2Forward(m,data)
data=data.*0.01;
for i=2:size(data,1)
for j=[4,5,6,9,12]
rf(i,j)= (12./m).*((1 + data(i,j).*(((j-3) + m)/12))./(1 + data(i,j-1).*((j-3)/12)) - 1);
end
end
end

Respuestas (2)

Stalin Samuel
Stalin Samuel el 18 de Dic. de 2015
Editada: Stalin Samuel el 18 de Dic. de 2015
i tried with random data..i am not getting any error
data= rand(100,100);%for example
m = 2
data=data.*0.01;
for i=2:size(data,1)
for j=[4,5,6,9,12]
rf(i,j)= (12./m).*((1 + data(i,j).*(((j-3) + m)/12))./(1 + data(i,j-1).*((j-3)/12)) - 1);
end
end

Walter Roberson
Walter Roberson el 18 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by