summaryrefslogtreecommitdiff
path: root/blocks/ajax-scilab/get_colormap_values.sci
blob: 35182fe3a61d9112e949980297faa65dd4e10b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function getvaluesfromcolormap(filename,colormapstring)
    f_temp = mopen(filename, 'wt');  // Creating a text file
    string_to_pass = strcat(["cmp_value_from_script = [",colormapstring,"]"]);  // forming string
    ok = execstr(string_to_pass,'errcatch');
    if (ok~=0) then
        mfprintf(f_temp, '%s', lasterror());  // catch error message if any
    else
        cmp_array = cmp_value_from_script(:);  // converts to one dimensional array
        arry_size = size(cmp_array);  // gives array of size eg. 96 1
        arry_length = arry_size(1);  // Get size of array eg. 96
        mfprintf(f_temp, '[');
        for i = 1:arry_length
            if i == arry_length then
            mfprintf(f_temp, '%.17g', cmp_array(i));  // print values of array
            else
            mfprintf(f_temp, '%.17g,', cmp_array(i));  // print values of array
            end
        end
        mfprintf(f_temp, ']');
    end
endfunction