Link to home
Start Free TrialLog in
Avatar of ezgigurkan
ezgigurkanFlag for Togo

asked on

Versatile Data Structure in MatLab

I need to plot multiple lines on an axis continuously, as in several lines might be drawn on an axis every time I push a button (I have my own simple GUI). The lines are not removed so lines are drawn on top of each other. The problem is that I need to keep certain variables associated with these lines, e.g.

- the handler (so that I can delete the line later on)
- 4-5 numbers
- 2 strings
- 3 vectors of various sizes (and the size of each vector might be different for different lines)

I'll have a button that should iterate through all the lines on the axis, access these variables associated with them and do calculations/delete lines/plot new ones. So I think I need an array of something but I don't know MatLab well enough. If that was Java I'd probably have to use a class, just to keep all these variables in one place.

If anyone knows about a good tutorial that'd be great. Or, if there aren't any such data structures in MatLab, what can I do to achieve what I'm trying to do?

Just to make it more clear, these lines represent Support Vector Machines (Regression). I need the variables for prediction when new data arrive. I'll be assessing different kernels and settings simultaneously.

Appreciate any help.
ASKER CERTIFIED SOLUTION
Avatar of Devom
Devom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ezgigurkan

ASKER

That's brilliant guys, thanks a lot. I might use both cells and structs. One thing though, how are handlers treated? Can I keep them in cells or structs? And is "handler" a type on its own or a special kind of string or something like that? Once I store it in a cell, can I dereference it without any hassle?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers guys...
Avatar of Devom
Devom

You can put handles in both cells and structs.  In the following I create a function handle, put it in a struct, then put both in a cell array.
>> a = @(x) 5*x;
>> a(5)
 
ans =
 
    25
 
>> b = struct('x5', a, 'num', 10)
 
b = 
 
     x5: @(x)5*x
    num: 10
 
>> b.x5(b.num)
 
ans =
 
    50
 
>> c = {a,b};
 
>> c{1}(c{2}.x5(c{2}.num))
 
ans =
 
   250

Open in new window