this post was submitted on 22 May 2024
28 points (96.7% liked)

Open Source

36666 readers
167 users here now

All about open source! Feel free to ask questions, and share news, and interesting stuff!

Useful Links

Rules

Related Communities

Community icon from opensource.org, but we are not affiliated with them.

founded 5 years ago
MODERATORS
 

Hello! In qalc I can do calculations using measuring units like this:

> 5 W * 3 s

  (5 watts) × (3 seconds) = 15 J

I'd like to be able to do something similar also in GNU Octave. I think the symbolic library could be a place to look at, but I found nothing "already done". Do any of you know of a way to achieve this functionality?

you are viewing a single comment's thread
view the rest of the comments
[–] Successful_Try543@feddit.de 6 points 11 months ago* (last edited 11 months ago) (5 children)

The Octave miscellaneous package has embedded GNU units as a function which should be helpful.

[–] tubbadu@lemmy.kde.social 3 points 11 months ago (4 children)

It looks interesting, but more focused on conversions than actual operations it seems:

octave:37> a.value = 100
a =

  scalar structure containing the fields:

    value = 100
    unit = W

octave:38> a.unit = 'W'
a =

  scalar structure containing the fields:

    value = 100
    unit = W

octave:39> b.value = 3
b =

  scalar structure containing the fields:

    value = 3
    unit = s

octave:40> b.unit = 's'
b =

  scalar structure containing the fields:

    value = 3
    unit = s

octave:41> a*b
error: binary operator '*' not implemented for 'scalar struct' by 'scalar struct' operations
[–] Successful_Try543@feddit.de 4 points 11 months ago (3 children)

I think I've found a solution. Matlab has implemented symunits in the symbolic toolbox and I've found the original? on Github. Hopefully it is compatible to GNU Octave.

[–] tubbadu@lemmy.kde.social 4 points 11 months ago

This looks very VERY promising! I'll try to install it tomorrow and Post here the results! Thanks?

load more comments (2 replies)
load more comments (2 replies)
load more comments (2 replies)