PROBLEM
I have two tools written in MATLAB (I am not the author):
the first allows me to retrieve some data from a SQL database, but it works only on MATLAB 64bit (I have MATLAB 2016b 64bit).
the second uses the data retrieved from the first tool and, through
a DLL compiled on a 32bit system, it gets some outputs. As said,
this tool works only MATLAB 32bit (I have MATLAB 2013a 32bit).
What I would like to do is:
get the data from SQL, in MATLAB 64bit
"send them" in some way to MATLAB 32bit
run the tool on MATLAB 32bit
"return" the outputs from MATLAB 32bit to MATLAB 64bit
I know a solution may be found using IPC mechanisms, but I am not sure how to find them or how to use them in MATLAB. Does anyone ever worked with this kind of stuff?
Looking into the MATLAB documentation I saw that it is possible to create a COM object, but I am not sure how to use it to run some functions in MATLAB 32bit.
SOLUTION
As suggested by #nekomatic below, everything works for me if I run the code in the way suggested, but excluding -automatic from the system command below.
The final system command is in the form
system('"C:\path\to\R2013a\matlab.exe" -wait -r "mycommand; exit"')
mycommand is a MATLAB script which loads the input file, it does something and then it saves an output file.
If you don't need this operation to be fast, the easiest way to do it is probably:
Save the data from 64-bit MATLAB as a .mat file
Use the system command to start an instance of 32-bit MATLAB
Run a script in 32-bit MATLAB that reads the data from the file, processes it and saves it
Read the result back in to your 64-bit program.
For example the 64-bit code (excluding error handling, current folder setup, etc) might look something like this:
delete result.mat % Delete any result from the previous run
save(data.mat, '-v7.3') % usually best to specify the .mat format to use
system('"C:\path\to\R2013a\matlab.exe" -automation -wait -r "mycommand; exit"')
processedData = load('result.mat')
where mycommand is your MATLAB R2013a script that reads the data from data.mat, processes it, and saves the result in result.mat.
More data on the startup options for R2013a here (assuming Windows) and on the system command for R2016b here. You may need to be signed in with a Mathworks account to see documentation for older releases, but if that's a problem just look in the help in your respective MATLAB installations.
Related
Is there a difference from running the same exact Maple commands to export a plot, when run from GUI interface, using worksheet, vs. from plain text .mpl file using command line Maple?
The following code runs OK from the GUI worksheet, but gives error
Error, invalid FONT specification when run from cmaple.exe.
This is on windows 10.
#file T1.mpl
currentdir("C:/TMP"); #or any other folder of your choice
plotsetup(default); #start from default
#the following commnad below export a plot to a file
plotsetup(ps, plotoutput="t.ps",
plotoptions=`color,noborder,portrait,height=250`);
p0:=DEtools:-DEplot( diff(y(x),x)=x, y(x), x=-2..2, y=-2..2,
'color' = "#00aaff",
'arrows'='medium',
'labels'=["",""],
'thickness'=1
):
#this will send the plot to a file.
print(plots:-display([p0],'view'=[-2..2.4,-2..2.5],
axis=[tickmarks=['color'='red']],
font=["Times",bold,8]
)
);
#ERROR SHOWS HERE
plotsetup(default); #rest back to default
The print command above, does not actually display anything, even on the GUI, since it was redirected to go to a file.
The above code works with no problem in the GUI interface, and the plots is exported OK to t.ps file.
I am trying to run the large Maple code I have from .mpl using command line Maple, hoping it will be faster than in worksheet, but the above problem is making it not possible.
First time trying cmaple.exe
Command I used is
"C:\Program Files\Maple 2018\bin.X86_64_WINDOWS\cmaple.exe" T1.mpl
May be I need an option to add to the command above?
This is using Maple 2018.1
The plot export driver in the Commandline Interface (CLI, aka TTY) does not know about the more modern calling sequences allowed for the various font related plotting options.
In modern Maple the font options can be specified using strings instead of names. That helps users avoid issues with assigning to alternative all-caps name forms, not all of which are protected names.
Unfortunately, it seems as if the CLI plot export driver does not know about the newer string forms. I will submit a bug report.
But you can still use the older, all-caps, name form.
Replace,
font=["Times",bold,8]
by,
font=[TIMES,BOLD,8]
Back when I was quite current with Maple, the answer to this question would have been: the GUI and the TTY version use different plot drivers. And the TTY plot drivers are not as well maintained as the ones for the GUI, and so more recent features do not always work for them.
I am guessing that this is still the case, and that the TTY plot driver doesn't know about fonts.
When starting Matlab, I must now add new paths in order to get access to my functions. However, these paths cannot be saved, and I get the following message:
“MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use the pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the directory from which you start MATLAB).
Do you want to save pathdef.m to another location?”
Before that, it works perfectly fine.
I tried the following solutions, but none of them did work:
restart the computer
restart Matlab
start Matlab as Administrator
re-install Matlab
re-install Matlab directly in C:\ (not in C:\Programs)
share Matlab-folders
check the number of „pathdef.m“ (and there is only one)
change UAC to the smallest level
try another license
The problem seems to be between Windows and Matlab. I have Windows 8.1 Pro (64-bit), and I used Matlab 2015a.
Any help to solve the problem would be much appreciated!
I just bought the student version of Matlab 2013. I have three well log files (.las) and I have downloaded them onto my computer.
When I open matlab I think it has to deal with either retrieving the .las file, or setting the path to get the functions. When I try to even type help readlas it gives me this error:
"Undefined function 'readlas' for input arguments of type 'char'."
Where do I set my path? How do I let Matlab access those three well log .las files?
MATLAB does not have any built-in capability to read LAS well log files. There is no function readlas supplied with MATLAB. If you have a program that uses a command readlas, you will need to contact the author of the program to obtain the code for readlas, and then add the directory containing readlas to your path. If you already have readlas, then just add its directory to the path.
There are freely available third-party tools that can read LAS files into MATLAB - one of the most common is Seislab, available here from the MATLAB Central File Exchange. However:
It's likely that the way Seislab reads in LAS data differs from the way your readlas reads it in, and I would doubt that you can simply replace your readlas with Seislab's read_las_file without changing quite a few other things.
Seislab is in general a horrible piece of software that I do not recommend you use unless you really have to.
Hope that helps!
Installing Matlab toolboxes
This looks to be a question about how to install a Matlab toolbox so that Matlab can find it. These look like the relavant links
how to install a toolbox to matlab if I do not have administrative authorization
How to install toolbox for MATLAB
How do I add a new toolbox to my already installed Matlab version?
Matlab tools to read LAS (Log-Ascii-Standard) files.
Readlas
readlas looks to be part of CREWES Matlab toolbox:
https://www.crewes.org/ResearchLinks/FreeSoftware/
Description
https://www.crewes.org/ForOurSponsors/ResearchReports/2013/CRR201331.pdf
The CREWES Matlab toolbox contains a script called readlas that has long had the ability to read version 1.2 and version 2.0 Log ASCII Standard (LAS) files. A new Matlab class called las that can handle all LAS versions has been written. The constructor reads an entire LAS file into memory and splits it into a Matlab cell string array using regular expressions. The readlas script is now a wrapper that creates a new las object and returns version 2.0 inputs suitable for logedit and syngram regardless of the LAS version of the input file. Since logedit and syngram cannot handle the multiple log data sections or logs containing character data (eg. lithology) that are allowed in LAS 3.0 files, or more than ten logs effectively, readlas provides graphical user interface (GUI) windows that prompt users to pick which log data section they would like to work on, and decide which logs within that section they want to edit. It also replaces any log character data with log null (numeric) values. The original readlas (pre 2013) is still available in the toolbox as readlas_old.
Las Toolbox
https://github.com/MosGeo/LasToolbox
A LAS file format toolbox for reading Las files in Matlab. All
information is loaded in a structured format including headers.
Currently, the code can only be used with LAS version 2. LAS version 3
is not currently supported.
Assuming a text file with 7718 characters (e.g. the contents cut and pasted from here)
The command fileread('myfile.txt') fails when I launch matlab with matlab -nodesktop but works in desktop mode.
Does anyone have any idea why?
If the number of characters in the text file is reduced to 1981 it works in -nodesktop mode.
Note:I do not know the exact number of characters at which it stops working.
Finally, I am using Matlab 7.8.0 (R2009a) on Windows7.
I can't reproduce this odd behaviour (Matlab 2010b & 2012b, both on Linux).
You could at least try to "debug" this type of behaviour by restricting the problem. The "fileread" routine does some checks on the file name (ischar, isempty), then opens the file (fopen), reads it (fread) and closes it (fclose) - rather simple basic stuff. For reference, type "edit fileread" into the command line of the matlab desktop and try running down the routine step by step.
If "fread" causes the whole thing to crash and if you're bound to this version of Matlab, try implementing a "fix". "fread" accepts a few more parameters than what is used in "fileread" (the file ID and the precision "char" only): FREAD(FID,SIZE,PRECISION,SKIP,MACHINEFORMAT). Specifying more parameters may help (wild guess but worth a try).
I'm using Matlab and need to get an ASAP2 (a2l) file exported from a Simulink model, using the Real-Time Workshop toolkit, from the command-line so it can be run as part of a batch operation.
I know that the process is possible by following the standard procedure for generating an ASAP2 file from a model, via the GUI, but this is no use to me in this instance as it requires user interaction with the GUI.
I've scoured Google and the Mathworks forums for an answer to this one but have come back with nothing; so does anyone know the command to generate an a2l file from the Windows CLI?
Thanks for any help you can offer.
Is the a2l file being generated when you press Build or Generate Code on the GUI? If so, the command-line equivalent is
rtwbuild(model);
Re-reading your question, I think you might be asking how to generate the file from a Windows command prompt. You can startup MATLAB and have it run any command using the -r option,
% matlab -r "load_system('model'); rtwbuild('model'); quit;"
Or you can write a a script to do all this, and call that script.