About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
  • Last update: 5 years ago
  • Total downloads: 40
  • Operating system: Linux, Mac OS X, Win All, BSD, Solaris
  • Publisher: Petropoulos
See full specifications

scripts default iconA multi conditional goto-like implementation in Matlab (Scripts) Publisher's description

Enough debate has been devoted from time to time to the luck of "go to" in Matlab

1. Introduction

Enough debate has been devoted from time to time to the luck of "go to" in Matlab.
Ourselves being somewhat devoted followers of structured programming, we rarely use
it in our FORTRAN applications and implementations. However, one cannot help that
sometimes there exists this need of a "quick and dirty" redirection within a code.
Nevertheless, we are fully aware that a "go to" implementation in Matlab would lead
to a lot of unacceptable coding. The "for entertaining purposes" "go to" implementation
of Husam Aldahiyat as presented in File Exchange of Mathworks triggered us into trying
it in a long waiting FORTRAN to Matlab conversion of a subroutine, that needs to perform
a set of conditional "go tos". This "go to" did not actually work for us. Its main
problem is that it is designed to handle "go to"s that do not transfer control to other
.m code for the same application. Consequently, we decided that it was high time to try
and implement our FORTRAN subroutine with conditional "go tos" in Matlab, using structured

2. Our conditional "go to" problem

We need to guide our code, so that to proceed to a series of different steps, depending
on choices. As it happens our choices are quite many. In order to differentiate these
choices from each other we gave each one a unique number between 0 and 63. It is obvious
that each choice number can be a result of summing up 0, 1, 2, 4, 8, 16 and 32 or
equivalently 0, 2^0, 2^1, 2^2, 2^3, 2^4, and 2^5. In our code if sum = 0 nothing happens,
if sum = 1 then task#1 is performed, if sum = 2 then task#2 is performed, if sum = 4 then
task#4 is perforned, if sum = 8 then task#8 is performed, if sum = 16 then task#16 is
performed and finally if sum = 32 no specific task is assigned and this choice number
is reserved for provisional use. In other words our code would not exploit all sum values
available. The actual implementation is useful for the calculation of chosen thermophysical
properties out of a set of available equations for water. To our best knowledge the
original of this implementation is to be found in:

Hendricks R.C., Peller R.C., Baron A.K., "WASP - A Flexible FORTRAN IV Computer Code of
Calculating Water and Steam Properties", Report No. NASA Technical Note TN D-7391, NASA,
Washington D.C. 20546, USA, 1973.

3. The FORTRAN implementation

It can be found in the .zip file as total.f subroutine

4. The Matlab implementation

It can be found in the .zip file as total.m function

5. Some discussion

It was not that straightforward but it is evident that a FORTRAN code with such a
complicated set of conditional "go tos" invoking some programming decisions, could be
implemented in Matlab as well. In this particular case the JPCi variables which govern
the conditional choice decisions are included in the m code function, while they are
communicated to the FORTRAN subroutine, using COMMON blocks calling a BLOCK DATA subprogram.
Furthermore, attention should be paid that the implementation presented is based in a system
of "functions that call other functions". Such a programming environment in Matlab calls for
using only static variables that should be communicated "to and from" as inputs and outputs
of functions and not as parts of global scripts.

S.T. Pachitsas, Student of Mechanical Engineering
N.P. Petropoulos, Lecturer
Nuclear Engineering Department
School of Mechanical Engineering
National Technical University of Athens
15780 Athens, GREECE

System Requirements:

MATLAB 7.8 (R2009a)
Program Release Status: New Release
Program Install Support: Install and Uninstall

A multi conditional goto-like implementation in Matlab (Scripts) Tags:

Click on a tag to find related softwares

Is A multi conditional goto-like implementation in Matlab (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.