w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
When running external commands in Mathematica, how to use external and internal variables simultaneously
The filename parameter should be a String. Converting an expression to a String is not robust as it will be parsed first and spaces may be added or lost, among other changes, even if the function is given the attribute HoldAllComplete. Instead use: f[filename_String] := Import["!grep 'keyword' " <> filename, "Text"] Then: f["file.txt"] Try asking your future questions on the proper Stack Exchange site:

Categories : Bash

Running Functions in GUI matlab
You're problem is that call Histogram and pass it str: Histogram(str) But you don't define Histogram to expect input: function Histogram What you need is something like this: function Histogram(str) % do something with str

Categories : Matlab

Mathematica antialiasing algorithm
One of the most used algorithm for drawing unaliased lines is Wu's line algorithm. On this basis, you can draw polygons easily; this site explains how to derive this algorithm to draw ellipses.

Categories : Algorithm

Mathematica MonomialList Not Working
Your basic problem is that Mathematica doesn't recognize your expression as a polynomial (which you can verify with PolynomialQ[expression]) due to the q^-1 term. Fortunately, there is another easy option. The Collect function will take your expression and group terms with the same power of q, and because this is a sum expression, we can convert it to a list with the apply operator: yourMonomialList = List @@ Collect[yourExpression, q]

Categories : List

Running matlab in background with an interface
A MATLAB command can be executed in the background with the following line: matlab -nosplash -nodisplay -nodesktop -minimize -r "run [your_script_path]; exit" With this configuration, you can run a script without a display and then console is closed. However, this option has too much opening/closing time overhead and two more feasible options can be: using another scripting language which is light weight like Python or implementing the GUI directly in MATLAB.

Categories : Java

An issue running fmincon in matlab
As @grantnz points out try: [pOPT, fval] = fmincon(@(p)fRSS(p),[.01 .01 .01],A, b, Aeq, beq, [0 0 0], [1 1 1], [], options); fmincon expects values of upper/lower for all variables.

Categories : Matlab

Show whether the GUI is running or not in matlab GUIDE
You could try doing set(handles.edit_text,'String','Running...'); drawnow; %a bunch of code... The GUI might not be updated until you get to set(handles.edit_text,'String','Ready.'); So forcing it to update with drawnow might work for you.

Categories : Matlab

Adding a Third column of data in Mathematica
So I have two methods for doing this; both of them work fine, but I think the latter is better for technical reasons; although I have not tested their performance: First Method: lista = RandomInteger[{0, 10}, {10, 2}] (*{{1, 3}, {0, 3}, {5, 5}, {4, 2}, {1, 7}, {3, 6}, {2, 2}, {3, 1}, {7, 6}, {8, 10}}*) For[i = 1, i <= Length[lista], i++, PrependTo[lista[[i]], x]] lista (*{{x, 1, 3}, {x, 0, 3}, {x, 5, 5}, {x, 4, 2}, {x, 1, 7}, {x, 3, 6}, {x, 2, 2}, {x, 3, 1}, {x, 7, 6}, {x, 8, 10}}*) Second Method: lista = RandomInteger[{0, 10}, {10, 2}] (*{{0, 5}, {6, 0}, {4, 6}, {3, 2}, {8, 1}, {4, 9}, {0, 5}, {9, 10}, {3,0}, {8, 4}}*) X = ConstantArray[x, Length[lista]]; lista = Transpose[Prepend[Transpose[lista], X]] (*{{x, 0, 5}, {x, 6, 0}, {x, 4, 6}, {x, 3, 2}, {x, 8, 1}, {x, 4, 9}, {x,0, 5},

Categories : List

Running Stored Procedure from Matlab Only Returns 1 row
Strangely, it the code started working again. All I did was write some diagnostic code to count the number of records in the tables that latest_hl_tradables() queries. Initially those only returned 1 row. Then when they started returning all the rows. I don't know what changed.

Categories : Mysql

Automatic checkouts of Mathematica files from Eclipse TFS
If you're using TFS 2012 you can create a local workspace rather then a server workspace. Local workspaces work in a similar way to SVN and there is no need to check out files to edit them

Categories : Tfs

Function to create a string from an array (Mathematica)
First get a string representing your array. I hate single-letter variable names, and I follow the Mathematica convention of using an initial lower-case letter for the variable names I define) so let myArray = {{3/2, -1, -2, -2, -2}, {0, 3, 6, 10, 14}, {-6, 3/2, 5, 5, 5}, {19/2, -7, -35/2, -24, -61/2}}; then myArrayString = ToString[myArray,InputForm]; and StringReplace[myArrayString,{" " -> "", "," -> "#", "{{" -> "left ( matrix{", "}}" -> "} right)", "}" -> "#", "{" -> ""}] returns the string you want. If you want a function to do this, just smash it all together like this: ooForm[arr_List]:= StringReplace[ToString[arr,InputForm], {" " -> "", "," -> "#", "{{" -> "left ( matrix{", "}}" -> "} right)", "}" -> "#", "{" -> ""}] You

Categories : Arrays

Check List for an Abstract Quality in Mathematica
For example: Select[t, Head[#[[1]]] == P &] returns (* {{P[41, 42], 1}, {P[41, 43], 1}, {P[42, 43], 1}} *) Or: Cases[t, {P[_Integer, _Integer], _}] returns the same

Categories : List

Why is Matlab is not reading an empty cell while running an if statement?
The empties are indeed something to get used to. It's like working with inf or NaN; what should things like NaN==NaN or 1/0==inf return? There's special rules for these guys. Simple ones, but you have to get to know them. To make all the special rules for these guys less of a burden, more intuitive and more readable, MATLAB has special functions for them: isinf (to detect inf), isnan (to detect NaN) and isfinite (to detect either inf or NaN). The empties also have special behavior and special rules that require some getting used to. If you think about it, it all makes sense in the end: What should []==[] return? or 1==''? Empty, of course. And even if []==false is empty, [] is false when evaluated by an if. Easy right? :) Unfortunately, there is no equivalent of isinf or isnan to dete

Categories : String

dll Matlab instance throw an exception while running release in c#
An attempt was made to load a program with an incorrect format this is the key, and it means you are mixing platforms somwhow. A 32bit process cannot load 64bit dlls and vice-versa. If a process tries to do so anyway, it throws the above exception. You say you only changed from Debug->Release, so it's likely something that has to do with platform changed as well. Compare settings for all projects in the Configuration Manager. They all should be x86 or x64 (not AnyCPU). Which one depends on your matlab dll's platform (set when building it).

Categories : C#

How does a system like Wolfram Alpha or Mathematica solve equations?
I dealt with such questions myself some time ago. I then found this document about simplification of expressions. It is titled Rule-based Simplification of Expressions and shows some details about simplification in Mupad, which later became a part of Matlab. According to this document, your assumption is correct. There is a set of rules for manipulation of expressions. A heuristic quality metric is is used as a target function for simplification.

Categories : Algorithm

Matlab Connector/J really slow; running query directly is much faster
Try is to increasing the row increment in the fetch function. This reduces the number of times that Matlab goes extracts data from the results, and also reduces the amount of memory reallocation required. The default value is 1280. I would go much, much larger, until your computer runs out of memory. Try 10,000, 100,000, or even 500,000. If you start running out of memory, consider selecting fewer columns (as your application allows, of course). For example, replace MyCellArray = fetch(dbConn, IntradayQUERY); with MyCellArray = fetch(dbConn, IntradayQUERY, 100000); and see what happens.

Categories : Mysql

How to pass image to matlab script running in LabVIEW environment
Break out your image channels into uchar 2D arrays using IMAQ (1 for each R, G, B, and Alpha). Pass those in and either reconstruct it in Matlab or operate on the different channels depending on the algorithm.

Categories : Matlab

Matlab : running an m-file from commande-line and get the results/output
Since I do not have a copy of matlab I cannot check this but I assume if you run it using command line interface (CLI) it should print output to STDOUT (i.e. your terminal window when calling it manually). In this case you should be able to re-direct all text output to a file when calling the script without a need to modify the script itself by C:...matlabin> matlab -wait -minimize -nodesktop -automation -r "run('C:...Source2.m');exit;" > FILEPATH I hope this is what you want and the above soultion works for you (on Windows it seems to me?). If you do not understand this solution you might want to read on "output re-direction", it can be very handy in many cases. If I got your question wrong and you knew about all that, sorry for boring you with basic stuff. However, when i

Categories : Matlab

Running script 'skript_name' gives error: Undefined function or variable 'skript_name' in Matlab
So I solved a similar problem. I added the current folder to path(path documentation). I tried 'which skript_name' and it gave me the correct folder. But it still showed the same error. My problem was that my skript_name had a hyphen('-') in the file name. Matlab does not like hyphens(here). I changed the file name and it worked.

Categories : Matlab

How come the mex code is running more slowly than the matlab code
I'd suggest that if you can, you get in touch with MathWorks to ask them for some advice. If you're not able to do that, then I would suggest really reading through the documentation and trying everything you find before giving up. I've found that a few small changes to the way one implements the MATLAB code, and a few small changes to the project settings (such as disabling responsiveness to Ctrl-C, extrinsic calls back to MATLAB) can make give a speed difference of an order of magnitude or more in the generated code. There are not many people outside MathWorks who would be able to give good advice on exactly what changes might be worthwhile/sensible for you. I should say that I've only used MATLAB Coder on one project, and I'm not at all an expert (actually not even a competent) C prog

Categories : C

Mathematica: Applying a function to a list of list
When I change your code, It gives: Total[{{a1, b1, c1}, {b1, b2, b3}, {c1, c2, c3}}] {a1 + b1 + c1, b1 + b2 + c2, b3 + c1 + c3} When Total take a list argument, It just add the members, in your case, It adds {a1, b1, c1},{b1, b2, b3}, {c1, c2, c3} But they are not the same dimension, so you cant get the right answer. In this case,Map should be used. Map[Total,{{a1, b1, c1}, {b1, b2, b3}, {c1, c2, c3, c4}}] or Plus @@@ {{a1, b1, c1}, {b1, b2, b3}, {c1, c2, c3, c4}}

Categories : List

Will Matlab standalone be faster than Matlab from UI for long execution code?
Applications built with MATLAB Compiler should execute at pretty much exactly the same speed as within MATLAB. MATLAB Compiler does not convert your MATLAB code into machine code in the same way as a C compiler does for C. What it does is to archive and encrypt your MATLAB code (note, it properly encrypts it, not just pcodes it as a comment suggests), create a thin executable wrapper and package them together, possibly also with MATLAB Compiler Runtime (MCR). MCR is very similar to MATLAB itself, without a graphical user interface, and is freely redistibutable. When you run the executable, it dearchives and decrypts your MATLAB code and runs it against the MCR. It should run exactly the same, both in terms of results and speed. Very old versions of MATLAB Compiler (pre-version 4.0) work

Categories : Matlab

How to apply a trained Matlab neural network from C++ without call to Matlab?
Of course it is possible - neural networks are clear mathematical models. All you need is a compatible representation, where you have stored: network topology (number of neurons in particuluar layers) network weights (between all neurons) network activation functions (for each neuron) And that's all. The exact solution depends on what matlab library you are using for neural networks. There is a "standard" for prediction models called PMML, which can be loaded by for example Weka libraries. Either way - it is easy operation, so you can also implement it by hand by simply storing all the numbers in the text file and simulating network in the C++ (as the "forward" phase of the neural network is just few lines of code - the training part is the long one).

Categories : C++

Matlab: Improper index matrix reference (or outsmarting matlab)
In the latest versions of MATLAB (13a/13b) there's a unit testing framework built in that looks very similar to what you're attempting. Instead of expect(myfibonacci(0)).toBe(0); you would write import matlab.unittest.constraints.IsEqualTo testCase.verifyThat(myfibonacci(0), IsEqualTo(0)) (You could also/instead have assumeThat, assertThat, or fatalAssertThat). If for some reason you wish to implement your own framework, note the small difference in your syntaxes - you have a dot whereas MathWorks have a comma between myfibonacci(0) and the test condition. In MATLAB you can't index into the result of a subscripted expression like that (well, you could, but you would have to overload subsref, and that's a world of pain, trust me). So the way they've done it is to introduce the test

Categories : Matlab

Launching Matlab from java ProcessBuilder, Matlab console doesn't appear in Mac OS 10.8
You need to specify that MATLAB is to run with a visible UI by making use of the -desktop flag. I don't believe this is documented. So the command you need to run is matlab -desktop -r "initMatlab;runJavaUI;" I've created a Java library called matlabcontrol that can abstract all of this away from you. It can launch MATLAB while running on Windows, OS X, and Linux and then allow you to interact with MATLAB via eval and feval commands. matlabcontrol's code to launch MATLAB is located in matlabcontrol.RemoteMatlabProxyFactory's createProcess(...) method. If you make use of matlabcontrol as a Java library you won't directly interact with either this class or this method.

Categories : Java

MatLab-->csv: Export data to csv file using dlmwrite in Matlab
I think the problem is that you write the names to a file at the local folder and not the other folder. fldr = fullfile('c:','Data_Analysis'); nomFile=fullfile( fldr, 'Test.csv' ); fid=fopen(nomFile,'w'); fprintf(fid,'%s,',names{:}); fprintf(fid,' '); dlmwrite(nomFile,A,'-append'); fclose(fid);

Categories : Matlab

MATLAB: checkmark in MATLAB figure with LaTeX interpreter
it's not pretty, but might be good enough: xlabel('$surd$','interpreter','latex') or look here for other things that look like a tick http://detexify.kirelabs.org

Categories : Matlab

Run Matlab executable file with MATLAB Compiler Runtime (MCR)
It simply means that you don't have rights to run PROGRAM. What is the output of the command: ls -l PROGRAM ? Maybe you've compiled this program as a root? Try to change the access using chmod.

Categories : Matlab

MATLAB - What are the units of Matlab Camera Calibration Toolbox
I know next to nothing about matlabs (not entirely true but i avoid matlab wherever I can, and that would be almost always possible) tracking utilities but here's some general info. Pixel dimension on the sensor has nothing to do with the size of the pixel on screen, or in model space. For all purposes a camera produces a picture that has no meaningful units. A tracking process is unaware of the scale of the scene. (the perspective projection takes care of that). You can re insert a scale by taking 2 tracked points and measuring the distance between those points. This is the solver spaces distance is pretty much arbitrary. Now if you know the real distance between these points you can get a conversion factor. By doing: real distance / solver space distance. There's really now way to kno

Categories : Matlab

Matlab density plot, Heat map, Matlab
You can control the colour of each point like so: scatter(x1, y1, [], C) where C is the same size as your x1 and y1 matrices. Now if you describe the rules of how you want this heatmap colour modulation to happen, we can help you construct C from x1 and y1...

Categories : Matlab

Call matlab from c++ using VS2010 and matlab 2007a
This is probably very late reply but this sample code of mine may help you. #include<iostream> #include<math.h> #include<engine.h> #pragma comment (lib, "libmat.lib") #pragma comment (lib, "libmx.lib") #pragma comment (lib, "libmex.lib") #pragma comment (lib, "libeng.lib") using namespace std; const int N = 9; //Number of grid points int main() { // start matlab engine Engine *ep = engOpen(NULL); if (!(ep = engOpen(""))) { fprintf(stderr, " Can't start MATLAB engine "); return EXIT_FAILURE; } int i, j; // Grid creation with aspect ratio r double sum_r = 0, r = 1; for (i = 0; i < N-1; i++){ sum_r += pow(r,i); } double dx0 = 1 / sum_r; // calculate first dx double dy0 =

Categories : C++

How to get the Matlab workspace associated with the current Matlab project in C#?
I have already the solution, the way is the next: Create a .m file (for example SaveWorskpace.m) con this information: save test.mat Add SaveWorskpace.m at the project with Matlab Compiler Deployment Tool. Compile the project with Matlab Compiler Deployment Tool Add reference at the c# project Call function SaveWorkspace() Ready, you have variables save in the workspace test.mat

Categories : C#

compile a matlab gui for win 32 system using 64 bit win and MATLAB
As far as I know you cannot actually use 64 bit matlab to build a 32 bit program. When I faced the same situation, Mathworks recommended me to (also) install 32 bit matlab on my 64 bit windows. I did not try it, but that should allow you to build 32 bit programs again.

Categories : Matlab

How to use Matlab from JAVA without using the Matlab Compiler
If you have Matlab (but you don't have builderJA) then you can use matlabcontrol for using matlab functions in java.(There might be other alternatives too, but I don't know) If you don't have Matlab at all then you can "create the java version of the matlab function" in some other computer having Matlab and builderJA installed, and use the jar files in your own computer. You only need to have MCR (Matlab Compiler Runtime- Its FREE) installed on your computer. Strickly answering your question: Is there a way to do use Matlab from JAVA, but without the need to have the Matlab Compiler? The answer is: Yes, you can use it. Using matlabcontrol (A java API to interact with Matlab).

Categories : Java

MATLAB Compiler vs MATLAB Coder
I'm not an expert, but the Coder is described as generating standalone C/C++ code, making no mention of the MCR. I notice however that it says that it only supports a "subset" of the Matlab language, which you can read more about here. The Compiler appears to just package up your Matlab code as you suggested, so probably supports most features.

Categories : Matlab

Is it bad to let CSS3 infinite animations running, and leave the page. Is the animation still running invisibly?
If the user leaves the page completely (e.g. navigates to a whole new page or closes that tab) then the animations shouldn't keep running. If they somehow do keep being updated, it's because of a browser bug and you shouldn't worry about it anyway. However, CSS3 animations for hidden elements (display: none;, for instance) still get evaluated, since they are keyframe-based, and there might be a keyframe sometime in the future that would cause the element to become visible again. Imagine wanting to animate a box by first hiding it, then showing it again and making it flash. If CSS transitions would suddenly become disabled when the box is hidden, the animation would stop and the box would never appear again. And that's not what you want. Note: profiling your web page can be done e.g. in

Categories : CSS

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

Calculate latency for touch screen UI running on ARM controller board running Linux
There are 3 latencies involved in the above scenario 1. Time taken for the touchscreen to register the finger and raise an input-event. Usually a few milliseconds. Enable FTRACE and log the following with timestamps -- ISR -- Entry of Bottom-half -- Invoking of input_report() 2. Time taken by the app responsible for the GUI to update it. Depending upon the app/framework, usually the most significant contributor to latency. Add normal console logs with timestamps in the GUI app's code -- upon receiving the input event -- just before the command to modify the GUI 3. The time taken by the display to update. Usually within 15-30 milliseconds The final latency is a sum-total of the above 3 latencies.

Categories : Linux

In android: I want to check the service running or not if already running change the UI colors when i launch
Follow this code : private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager .getRunningServices(Integer.MAX_VALUE)) { if (YourService.class.getName().equals( service.service.getClassName())) { return true; } } return false; } Call this method in your activity like below : makeChangesInUI(isMyServiceRunning())

Categories : Android

I am trying to install my rails app onto a Ubuntu 10.04 box running in Vagrant (Virtualbox). I'm running into the following errors
The latest version of devise 3.0 fixes my devise errors. I am going to close this in favor of breaking out the second capybara error at Problems installing capybara-webkit 1.0.0 in Rails 3.2.10 on Ubuntu 10.04

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.