Skip to content
Analytica > Blogs > An Analytica advantage over MATLAB

An Analytica advantage over MATLAB

I’m working on a model translation project for the California Energy Commission, going from MATLAB to Analytica. The transportation system model I’m working with has variables with many dimensions, including time, vehicle type, fuel, mode, and vintage. The MATLAB implementation includes pervasive use of the repmat (repeat matrix) and the reshape functions, which obscure the core model logic (and looks like a pain to have had to implement). As I’m translating, I’m reminded of how nice Analytica’s Intelligent Arrays are to work with, for reasons I’ll illustrate below.

Many parts of the model are conceptually straightforward. For example, fuel cost is the product of fuel cost by vehicle type and number of vehicles of each type over time. Surrounded by the reshaping and repeating function calls necessary to perform a simple element-wise multiplication, this logic takes some time to figure out within the MATLAB code:

  dollarsPerMile = repmat(reshape(fuelPrice(car,:,:),
  [dimension.fuelType 1 1 dimension.Time]), [1 dimension.class
dimension.vintage 1]) ./ repmat(milesPerFuelUnit, [1 1 1
dimension.Time]);

  totalCost = sum(sum(sum(vehicles .* dollarsPerMile,3),2),1);

versus the Analytica implementation:

  dollarsPerMile := fuelPrice / milesPerFuelUnit;

  totalCost := sum( vehicles * dollarsPerMile, class, fuelType, vintage);

Analytica’s Intelligent Array abstraction takes care of this behind the scenes, so I just need to make sure I’ve implemented the correct logic. I don’t have to think about the dimensionality of the data until it’s relevant to the logic I’m implementing. Another example: in computing what fraction of the vehicle fleet is electric I need to calculate the size of the fleet to figure out my denominator, summing over all types of vehicles. When I do compute that sum, thankfully I don’t need to remember that vehicle type is the third of five array dimensions. (As I read through the MATLAB code, my scratch paper filled with of ordered lists of dimensions for the MATLAB arrays to track what dimension was being repeated or summed.)

So, if you’re working in MATLAB and find yourself using repmat and reshape, consider letting Analytica do that unenjoyable dimension management on your behalf so you can focus on building out a model to help you analyze whatever system or problem you’re tackling. You know, the fun stuff!

Share now 

See also

air conditioner outdoor unit

Building electrification: heat pump technology

Lumina set out to build a useful tool to assess the benefits of heat pumps. Learn more about heat pumps and their impact.
More...

Heat pumps 101

Heat and cool your home while saving energy and reducing emissions by adopting heat pump technology. Learn more about this transition and heat pumps by watching this webinar.
More...
Heatpump

Navigating the heat pump landscape

Fort Collins, Lumina, and Apex Analytics have created a tool to help reduce greenhouse gas emissions by optimizing building electrification programs.
More...

US gas leaks much larger than previously estimated

A new Stanford-led study on natural gas leak rates from oil and gas activity across a large fraction of the US are about 3x more than previous government estimates. The
More...

See also

Building electrification: heat pump technology

Lumina set out to build a useful tool to assess the benefits of heat pumps. Learn more about heat pumps and their impact.

More…

Decision making when there is little historic precedent

Learn how to make decisions and strategic plans in uncertain situations, where historical data is not available. See how to model this in Analytica with clarity and insight.

More…

Does GPT-4 pass the Turing test?

In 1950, Alan Turing proposed “The Imitation Game”, today known as the Turing test, as a hypothetical way of measuring whether a computer can think [1]. It stakes out the...

More…

What is Analytica software?

Analytica is a decision analysis tool that helps you generate clearer and more justified results through modeling.

More…

Download the free edition of Analytica

The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


    Analytica Cubes Pattern

    Download the free edition of Analytica

    The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

    While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


      Analytica Cubes Pattern

      Download the free edition of Analytica

      The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

      While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


        Analytica Cubes Pattern

        Download the free edition of Analytica

        The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

        While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


          Analytica Cubes Pattern

          Download the free edition of Analytica

          The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

          While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


            Analytica Cubes Pattern

            Download the free edition of Analytica

            The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

            While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


              Analytica Cubes Pattern