سؤال

I am a newbie to Octave, and really struggle with a Matlab script I was given. I am trying to make it run in Octave. The function is defined as

 function terrainParameter = calculateTerrainParameter(surfaceTopography,x2,x3,x4).

The inputs x2,x3,x4 are clear. What I have troubles with is x1, the surface Topography. In the script follows:

latitudeStart = surfaceTopography.xllcorner;
latitudeStep = surfaceTopography.cellsize;
latitudeStop = surfaceTopography.xllcorner + latitudeStep * (surfaceTopography.ncols - 1);

longitudeStart = surfaceTopography.yllcorner;
longitudeStep = - surfaceTopography.cellsize;
longitudeStop = surfaceTopography.yllcorner + latitudeStep * (surfaceTopography.nrows - 1);

[latitudeGrid longitudeGrid] = meshgrid(latitudeStart:latitudeStep:latitudeStop,longitudeStop:longitudeStep:longitudeStart);

altitudeGrid = surfaceTopography.data;

Now: the input "surfaceTopography" (=x1), how should that look like? I have an ARC grid (DSM.arc). I managed Octave to read it - without the header (DSM) -and built a 3D mesh. But when I run the script the output reads usually

matrix cannot be indexed with .

when I try "DSM" or "DSM.arc" as input for "surfaceTopography". Or should the mesh (meshgrid) be the surfaceTopography?

I am not sure my question is clear, but I hope it is and someone can help me here.

Thanks in advance, Peter

هل كانت مفيدة؟

المحلول

Problem solved: As rayreng and carandraug suggested, I needed to create a struct.I did this via a executable I run from terminal (or, alternatively as .m from Octave):

    #! /usr/bin/octave -qf
    load DHM
    surfaceTopography.xllcorner = 944452;
    surfaceTopography.yllcorner = 6452389;
    surfaceTopography.cellsize = 1;
    surfaceTopography.nrows = 144;
    surfaceTopography.ncols = 144;
    surfaceTopography.data = DHM; 

    calculateTerrainParameter(surfaceTopography,30,20,7)

Thanks again!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top