Struct Contents Reference From a Non-Struct Array Object

I had to get in touch with Mathworks viz a viz a problem concerning the passing of a Java object to various workers of the parallel computing toolbox of Matlab. I got the following answer from the support. I am sure someone is going to encounter the same problem and might need help. Please peruse.

Hello Muhammad Adil,

I am Preethi and I am writing in reference to your Technical Support Case #03167864 regarding ‘Struct contents reference from a non-struct array object.’.

I understand that you are seeing an error when trying to call a function of a serialized Java Object in parfor loop
One of the possible reasons would be that the Java class is added in the dynamic java classpath. The workers are not able to access the dynamic java classpath since it is specific to that session of MATLAB, and all the workers run on different MATLAB processes. Use one of the following two workarounds to make this work:

1) Please add the java class to the “static” java class path. Instructions on how to do this can be found in the following documentation link: <>

This will make sure that all MATLAB processes will have access to the same java class path.

2) The “javaaddpath” function to add entries to the dynamic Java class path can be executed on all the workers using the “pctRunOnAll” command as follows:

>pctRunOnAll javaaddpath(‘path’) %Replace ‘path’ with the appropriate path

Please make sure that the parallel pool is running before running this command.
I believe this will help in resolving the issue you are facing. I am thus marking this case as closed for now. If the issue persists, please feel free to reply to this email and I will be happy to reopen the case and help you further.

Please preserve the Reference ID in further correspondence on this query. This allows our systems to automatically associate your reply to the appropriate Case.

Preethi Ayyamperumal
MathWorks Technical Support

File Exchange and MATLAB Answers:

Photo by ZapTheDingbat

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Object-oriented Scripting in Octave and Matlab

I am facing a problem of implementing a board game. In this, a smart agent is expected to raise havoc on the board while exploring it. I was thinking that if the agent was implemented as an object, it would make life a lot easier from the point of view of implementing the game.

Both Matlab and Octave allow object-oriented scripting. An object can have its own fields and methods. The way it can be accomplished is slightly different for each of these languages. In Matlab, you can create a class and define its methods in the same file that you used to create the class. In Octave, you have to create a folder for a class. You put all the methods for that class in that folder as m-files.

Create a Simple Class – MATLAB & Simulink

The basic purpose of a class is to define an object that encapsulates data and the operations performed on that data.

GNU Octave: Creating a Class

GNU Octave: Creating a Class

Photo by sapphirebluebird

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Game Programming With Matlab and Octave

I am currently reading about ways to develop board games in Matlab. I will be really pleased to be able to develop other kinds of games as well. Here on this page, I am just throwing the links and articles that I find useful. To begin with here is a nice thread on quora. More link as follows:

Matlab source code of some popular games such as sudoku and tic-tac-toe. This can help you glean what goes inside the code.

Matlab Games

Matlab Games

Some games (and their codes) showcased on Mathworks and other sites.–tech-demo–the-best-matlab-shooting-game-ever

Lunar Lander | Joe Weinhoffer

Worked with a partner to create a Lunar Lander game using MATLAB. The object of the game is to successfully land the ship onto one of the platforms without crashing into any obstacles or running out of fuel. The force of gravity constantly acts on the lander, requiring use of the ships thrust to maneuver.

Yet another game in Matlab: Risk. For those of you who are familiar.

RISK board game battle simulation – MATLAB Cody – MATLAB Central

Given two positive integer inputs, a (attacker army units) and d (defender army units) return the probablity of victory (from 0.000 to 1.000) to +- 0.02 accuracy. The rules are given below for those unfamiliar with the game. In the board game RISK battles are determined by the conflict of armies, namely the attacking army and the defending army.

Here is a nice article about the implementation of minesweeper in Matlab. It could be really useful for understanding how to develop a game board in Matlab.

MatLab Minesweeper – ENGR005_2009

The motivation for this project came from an old desire to create a game that actually works. MatLab has provided a new outlet to attempt to reach this goal. I choose minesweeper because it presented an obvious opprotunity to use matrices for which MatLab is designed.

Ability to draw voxels (cubes, cuboids) could be of some value, as it was showcased on a gaming site and is available through Mathworks.

Voxel – File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

RoteAugen/flappybird-for-matlab – File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

This tutorial on youtube about creating GUIs in Matlab with GUIDE could be useful. Review this as you listen to a nice song.
Create a simple game in matlab gui Part1

This is a nice tutorial and contains links and videos for famous games implemented in Matlab.

Gaming in Matlab

I have recently been looking into how to make very advanced and beautiful GUIs in Matlab. The issue with this is that in Matlab, GUIs seem to be somehow limited compared to other languages. Historically, Matlab was supposed to be a numerical plate-form to quickly put together new ideas for computation.

Following is somebody’s website who has implemented numerous board games in Matlab. This can be really good to understand board development in Matlab.

MATLAB Fun Toolbox

This page contains my library of MATLAB m-files for a simple game and everything else that I make just for fun. All of these m-files are free and you may use or modify them as you like. To download the m-files, simply click the link on each m-file name and a pop-up window will appear, allowing…

I also wanted to list a few games that are implemented specifically in Octave, as many people do not have access to Matlab or they don’t like it. Here is an implementation of tic-tac-toe in Octave. This could be nice to understand how graphics are rendered in Octave.


TicTacToe – Tic-Tac-Toe minimax algorithm implementation in Octave

This implementation of game of life in Octave can be really useful.

The Game of Life in Octave

The Game of Life is a simple cellular automaton invented by mathematician John Conway. The Game of Life consists of a two dimensional grid of cells. Each cell can be “live” or “dead”, often represented mathematically by 1 and 0.

This sounds like a really nice book that was written with the intention of teaching game programming with Matlab.

Matrices, Vectors, and 3D Math: A Game Programming Approach with MATLAB – MATLAB & Simulink

Matrices, Vectors, and 3D Math provides a resource to learn standard topics in Linear Algebra and

Here is a nice tanks game called Staker that is showcased on Mathworks. It is written in Matlab. It could be helpful in understanding how Matlab renders graphics.

Staker v0.6 – File Exchange – MATLAB Central

Description Staker is a 3-D artillery warfare game that was inspired by Tank Wars and Scorched Earth, BASIC games I played many years ago. This is just a beta version, so it doesn’t have everything in it that I would like. For instance, there is only one type of terrain to battle on.

Here is another nice tanks game that uses graphics.

File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

This chess game in Matlab can help draw a board at least. It integrates well with external chess engines.

Chess Master – File Exchange – MATLAB Central

Chess Master is a fully-functional chess graphical user interface (GUI) for MATLAB. Features: 1. Easily connect to any UCI-compatible external chess engine. I recommend Stockfish (see below for *easy* installation instructions!) 2. Read/write games in PGN format3. Board editor GUI to easily create/explore custom positions4. Move list GUI to navigate through games5.

This is a very nice piece of code that shows you how to draw cellular automata in Matlab/Octave.

10 lines of Matlab code (works also in GNU Octave): a simple Game of Life from cellular_automata

You will find this very handy as it shows how to use imshow to display a bunch of images in a plot without borders.

How to Make a Borderless Subplot of Images in MATLAB

Let’s say that you have a set of images that you want to tile using imshow() and subplot() in a MATLAB figure. By default, both functions add a padded space around the images to separate them, as this example shows: Result: However, what if you want to tile the images without any space between them?

The second edition of the book, Artificial Intelligence for Games, by Ian Millington and John Funge can be found here.

Artificial Intelligence for Games

Artificial Intelligence for Games [Ian Millington, John Funge] on *FREE* shipping on qualifying offers. Creating robust artificial intelligence is one of the greatest challenges for game developers, yet the commercial success of a game is often dependent upon the quality of the AI. In this book

The pdf of the book can be found here.

Finally, here are some links for pathfinding algorithms in Matlab.

A* (A Star) search for path planning tutorial – File Exchange – MATLAB Central

A tutorial that presents the A* search algorithm for determining the shortest path to a target.

A* Algorithm – File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

Demonstration of Astar (A*) – File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

A Star implemented in Matlab – File Exchange – MATLAB Central

File exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community

Photo by Flikkersteph -5,000,000 views ,thank you!

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Connecting to a HTTP Server Through Matlab

This post contains links to resources that can be useful for connecting to a HTTP server through Matlab. The links posted below particularly correspond to the urlread() function of Matlab.


collapse all Download the HTML for the page on the MATLAB ® Central File Exchange that lists submissions related to urlread. fullURL = [‘’ … ‘?term=urlread’]; str = urlread(fullURL); urlread reads from the specified URL and downloads the HTML content to the string str.

Here is a link to its variant, urlread2(), which adds extra functionality to the original urlread(). urlread2 makes extensive use of Java’s apis for http client-server connections. The java source files can also be downloaded from the following link for urlread2.

urlread2 – File Exchange – MATLAB Central

Version 1.1 Replacement for urlread. Example functions in the urlread2 file show how to make equivalent calls as are made in urlread. Helper functions can be written (some provided) to provide additional functionality without always needing to modify the urlread2 code.

Here is documentation that describes the functionality of urlread2().

Expanding urlread capabilities

I would like to welcome guest blogger Jim Hokanson. Today, Jim will explain some of the limitations that at one time or another many of us have encountered with Matlab’s built-in urlread function. More importantly, Jim has spent a lot of time in creating an expanded-capabilities Matlab function, which he explains below.

Photo by Ian Sane

If you found an error, highlight it and press Shift + Enter or click here to inform us.

Using TORCS With Matlab and Simulink

TORCS (The Open Racing Car Simulator) is possibly the most well known simulator for simulating racing cars. It is written in C++. It is a 3D car racing simulator. It is also used by the simulated car racing competition, hosted annually by GECCO.


GECCO 2015

This is CBBOC’s inaugural year. It’s designed to provide the GECCO community with detailed performance comparisons of a wide variety of meta-heuristics and hyper-heuristics on combinatorial problems, where the real-world problems which induce combinatorial problems have been categorized into those with no training time (good fit for out-of-the-box algorithms such as the Parameter-less Population Pyramid), those with short training time (good fit for typical evolutionary algorithms), and those with long training time (good fit for hyper-heuristics).


The TORCS simulator also has an interface for Matlab and Simulink. This means that controllers can be developed for TORCS using Matlab. Using Matlab simply means that the whole hassle of interfacing with TORCS should become a lot easier. The source code is present at GitHub.


TORCSLink – An interface between The Open Source Race Car Simulator (TORCS) and MATLAB/Simulink (or anything else…)

TORCS is also available through Ubuntu’s software center. You can install it from here.


TORCS, The Open Racing Car Simulator, is a car racing simulation, which allows you to drive in races against opponents simulated by the computer. You can also develop your own computer-controlled driver (also called a robot) in C or C++. TORCS is GPL (version 2 or later).

The following video shows how TORCS works on a user’s desktop.


Photo by SFB579 Namaste

If you found an error, highlight it and press Shift + Enter or click here to inform us.