I have a script that calls another program (EES - Engineering Equation Solver) and performs some calculations there and returns the results. The problem I am encountering is that everytime I call the EES from Matlab, it starts the EES but does not solve the EES equations. Instead, I have to then manually press the "solve" button inside the EES, close the EES and after that the results are returned to Matlab.
Is it possible to use a command inside Matlab to solve the EES equations automatically?
The current solution I have is the following, but it only starts the EES and does not solve it automatically:
system ('c:\ees32\ees.exe c:\EES32\testing\solverfile.ees /solve'); %call EES and solve
Thanks!
On a second thought, this is something that is dependent on the EES program and the commands that are possible to use there. So this is probably not the best place for asking this questions.
Related
I am trying to use a table within a parfor loop in MATLAB. This gives me "Transparency violation error. See Parallel Computing Toolbox about transparency" I'm trying to build this table so I can make a prediction using a trained classifier from the MATLAB classification learner app (trainedClassifier.prefictFcn(T))...so either I need to build a table within the parfor loop or need some alternative to a table that I can still feed into the classifier.
parfor i=1:100
acheck=1;
bcheck=2;
ccheck=3;
T=table(acheck,bcheck,ccheck);
end
This solution works for your particular problem:
parfor i=1:100
acheck=1;
bcheck=2;
ccheck=3;
T(i,:)=table([acheck,bcheck,ccheck]);
end
Note that in your original program you just overwrite existing values and end up with a one row table. I assumed that that was not intended. Actually, that would be the outcome of a for.
Also, since this is a parfor and T is created inside the loop (as well as acheck, etc.) using just T creates nothing at all. The variable is a temporary one, visible to each process locally and destroyed in global scope (more can be found here).
To fix both overwriting and accessibility the program assigns the each set of variables to each row of T. If square brackets are omitted, the program throws a transparency error. Unfortunately, I do not know why is that but it may be that the operations done by the table data-structure cause that. Maybe someone else will know the answer, for now this seem to solve your problem though.
How do I display the current value of a variable in the matlab command window? In matlab I usually use disp(var) and it will output the variable value into the command window. However in the MATLAB function block if I were to enter disp('hello') it doesn't show any output in the command window. I am using matlab 2014b.
You idea for displaying output value in the command window is not a good approach to solve your issue. I would suggest you look at scope block if you'd like to see the value during simulation. Or use To Wrokspace block if you'd like to output the value into main workspace.
For debugging your code and design, read and use Simulink Debugger should be helpful.
Matlab r2016b allows for functions to be embedded in scripts. I am trying to run this script, but an error occurs, and I do not know what rules I am breaking. Here is the script:
clear
clc
out=nestedvol(2)
function outvol=nestedvol(l)
outvol=2*l
end
x=4 %this line does not work.
This question continues off of In MATLAB, can I have a script and a function definition in the same file?
How could I get a script to continue after the embedded function ends? Would an anonymous function be appropriate for this?
The reason I ask this is because I make review scripts for chapters of the matlab book I am reading, so it would be nice to section areas of the code off. It seems like if any function is not included, ctrl enter does not work.
1 I run matlab without GUI, sometimes I would like to see commandhisoty by using commandhistory function, but I found that if I run matlab without GUI, the program cannot save any command history like the GUI matlab, are there some methods to solve this problem?
2 I tyied to use diary, but it seems that it can only save all commands and outputs. In addition, it seems that I should type diary every time when I open matlab, the default option is diary off. How to make it more convenient to use
I am tasked to design a GUI and I need to use variables and plots from a different mfile which I created earlier. I'm pretty confident about getting variables from the processing mfile but I'm not sure how to get the plots/figures.
So basically my question is whether I can get() a figure from my mfile and then set() an axes to that figure inside my GUI.
Note: The reason I am doing this is because I want to keep the processing of data separate from the GUI mfile. I could just dump all the processing in the callback of my process button but that's not good. I would also appreciate good coding practices for my case since I have never worked with GUI's before (only scripting with PHP and MATLAB)
Note2 (rundown of what has to be done): In the GUI we basically are supposed to load 2 files, we then press the "process" button and then 4 plots have to appear. All the processing code already exists in a previously written mfile (by me).
Thanks! :)
I figured it out myself! What I did was use gcf to get the current figure like so: output.worldmap = gcf I then passed the object back like so: setappdata(0,'output',output) and grabbed it again inside my callback function like so: getappdata(0,'output') and used the following function to set the axes set(output.worldmap,'CurrentAxes',handles.axes_worldmap) I also made sure that the correct axis was set before I actually ran my mfile which does the processing with axes(handles.worldmap)