Shyamkkhadka
Shyamkkhadka

Reputation: 1468

hash like object in octave

I have some built in function in octave as

function [val_a,val_b,params] = func_a(X,Y,alpha,params);
age = params.age
height = params.height

Here it seems the argument params of func_a contains multiple objects age, height. In general, params should be hash like

params = {"age" : 10, "height" : 30}

But it gives error in octave. How can I use it in octave or in matlab ?

Upvotes: 0

Views: 216

Answers (1)

Shyamkkhadka
Shyamkkhadka

Reputation: 1468

Thanks to all the commenter. I fount it is more like struct, but not hash or hash type object. Here is the solution:

field1 = 'age'
value1 = 10
field2 = 'height'
value2 = 30
params = struct(field1, value1, field2, value2)

Then we can access as params.age and params.height.

Upvotes: 1

Related Questions