You are using square brackets testc[Nx, Ny, c0] in calling your function when you should be using round brackets testc(Nx, Ny, c0)
I seem to remember that you are transitioning from Matlab - I think you’ll find with time that this is one of the key day-to-day improvements working in Julia compared to Matlab. Whereas Matlab uses round brackets both for indexing (e.g. my_array(1:5)) and function calls (e.g. my_function(argument)), in Julia square brackets are reserved for indexing and function calls work with round brackets, making the likelihood of introducing bugs by confusing the two a lot lower!
I would recommend against using any of this type of automatic conversion tool. As you can see, they don’t really work and in the end it will likely take longer time to use the tool than to do it manually. Also, if you want to program in Julia you still need to learn the language, and rewriting a program in another programming language is a great way to learn.
@Tamas_Papp , I used your suggested web ( tools, eg this one , translate a subset) to test a very very simple function, previously, to apparently little effect.
Please do not misrepresent what I said — as clarified in that topic, I never suggested that you use this tool, or any other.
That said, you are of course free to ignore advice from multiple experienced Julia users, but this case is a perfect demonstration of why translation tools will not help you. You would be much better off just learning Julia.
The thing is, your function has not been defined correctly, as it should be this:
function testc(Nx, Ny, c0)
ccc = zeros(Nx, Ny) # Erstelle ein 2D-Array mit Nx Zeilen und Ny Spalten
for i = 1:Nx
for j = 1:Ny
ii = (i - 1) * Ny + j
ccc[i, j] = c0 + ii
end
end
return ccc
end
Is that what you wanted to achieve? It works, as soon this funktion is called, using round brackets of course