Plotagem de Graficos Com Scilab

Temos aqui um programinha que gera um vetor de pares ordenados (x,Point(x)), cria um arquivo-tabela com os elementos desse vetor e depois plota esse arquivo-tabela em um gráfico usando o Scilab. Para que o programa funcione é preciso ter instalado o Scilab e um script que lê os dados da lista data.dat.

ploting graphics using a LUA script with Scilab!

Prog LUA

function Point(x)

        return { x = x, y = x^2 }

end

vetor = { }

i = #vetor

a = 0

b = 0.1

c = 0

while a < 3 do

vetor[i] = Point(a)

integral = vetor[i].y * b

c = c + integral

file = io.open("data.dat","a+")
file:write(vetor[i].x.." "..vetor[i].y.." "..c.."\n")
file:close ()
print(vetor[i].x.." "..vetor[i].y.." "..c)
i = i + 1

a = a + b
end
print(i)

os.execute("scilab -f scriptscilab.sce")

Script Scilab (deve estar no mesmo diretório do programa.LUA)

z = read("data.dat", 30,3)
plot(z(1:30,1),z(1:30,2))

voltar(back)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.