w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is there an equivalent for C# (or C++) keyword 'using' for Matlab?
A nasty way of doing so would be function my_using( params ) % % params should be a struct (NOT an array of struct!) % fn = fieldnames( params ); for ii = 1:numel( fn ) assignin('caller', fn{ii}, params.(fn) ); end Now you can call my_using in your function and all params in the struct will be created as variables in the function

Categories : C#

scipy equivalent for MATLAB spy
Maybe it's your version of matplotlib that makes trouble, as for me scipy.sparse and matplotlib.pylab work well together. See sample code below that produces the 'spy' plot attached. import matplotlib.pylab as plt import scipy.sparse as sps A = sps.rand(10000,10000, density=0.00001) M = sps.csr_matrix(A) plt.spy(M) plt.show() # Returns here '1.3.0' matplotlib.__version__ This gives this plot:

Categories : Python

equivalent from MATLAB to Python
Matplotlib offers nearly all plotting options Matlab does. Surface plots can be done as well: http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#surface-plots To load images scipy has a PIL-wrapper (no clown included, sorry), which loads matplotlib-compatible numpy arrays. To sum up, you want the following packages: numpy, scipy, matplotlib and PIL. The combination of those four libraries should give you all you need. Also check out the pylab interface of these libraries, as it is very similar to Matlab. Example that does what I believe you want to do: from mpl_toolkits.mplot3d import Axes3D from scipy.misc import imread from matplotlib.pyplot import figure, show from numpy import linspace, meshgrid, sqrt, sin, mean, flipud clown = imread('clown.png') fig = figure() ax = fig.gca

Categories : Python

What is the R equivalent of matlab's csaps()
Here is what I found in p. 16 of MATLAB/R Reference by David Hiebeler. [I don't use Matlab,however]. Fit natural cubic spline(S′′(x) = 0 at both endpoints) to points (xi, yi)whose coordinates are in vectors x and y; evaluate at points whose x coordinates are in vector xx, storing corresponding y’s in yy Matlab: pp=csape(x,y,’variational’); yy=ppval(pp,xx) but note that csape is in Matlab’s Spline Toolbox R tmp=spline(x,y,method=’natural’, xout=xx); yy=tmp$y

Categories : R

Equivalent of Excel Solver in Matlab?
Without Constraints You will probably end up finding the solution with fmincon or fminunc in MATLAB. For example, using fminunc because its syntax is a little less cluttered, you could start by defining your cost function in a separate file, named "NameOfFunction.m": function cost = NameOfFunction(w, a, b, c, Structure1, Structure2, Structure3) % Your code goes here, just remember that you return a scalar-valued cost from % this function. Note that fminunc and similar will try to minimize this cost function. If you need to maximize it, then just multiply your final cost by -1 at the end. Next, you create a handle to your function in your main file: h = @(w)NameOfFunction(w, a, b, c, Structure1, Structure2, Structure3); Where w is a vector of the variables that you want to optimize:

Categories : Matlab

Matlab gradient equivalent in opencv
You have to call Sobel 2 times, with arguments: xorder = 1, yorder = 0 and xorder = 0, yorder = 1 You have to select the appropriate kernel size. See documentation It might still be that the MatLab implementation was different, ideally you should retrieve which kernel was used there... Edit: If you need to specify your own kernel, you can use the more generic filter2D. Your destination depth will be CV_16S (16bit signed).

Categories : Matlab

In R what is the equivalent of "mod" function handle in Matlab?
There is a %% operator > 5 %% 1 [1] 0 > 5 %% 2 [1] 1 > 5 %% 3 [1] 2 > 5 %% 4 [1] 1 > 5 %% 5 [1] 0 > 5 %% 6 [1] 5 You can use ?'%%' to get its detailed description

Categories : R

Is there an equivalent of the python function id() in matlab?
For all handle-like objects the identifier analogue to id() is probably the double-converted value: >> h = uicontrol h = 9.7656e-004 >> handle(h) ans = uicontrol For non-handle type objects such a thing probably doesn't exists, since Matlab usually uses call-by-value instead of call-by-reference. So in general, upon changing a variable's value, there's no guarantee that the underlying object remains the same.

Categories : Python

Matlab: How to properly get a mask equivalent to 2^63-1?
I don't see the problems you report. On my computer (Matlab R2012b on 64-bit Ubuntu12.04): >> mask_fraction = uint64(9223372036854775807) mask_fraction = 9223372036854775807 >> uint64(2^63) - 1 ans = 9223372036854775807 Do you maybe run an older Matlab version? I also find the 'undefined function or method minus ...' error a bit suspicious. Do you have uint64 aliased to some other function? Try clear uint64 first ...

Categories : Matlab

Equivalent of Matlab's fread() 'float64' in Python
There is a delimiter between your data values producing alternating data and NaN on reading, for instance in matlab: NaN 2134 NaN 2129 NaN 2128 .... 1678 and with numpy: [ nan 2134. nan ..., 1681. nan 1678.] I get the same input using the code you posted either with Matlab or numpy(1.7). Note that the data is read from your dat file column-wise, not row-wise according to the pattern in your csv file. To get ALL of the data in numpy try a = fromfile(file=f, dtype=float64, count=-1)

Categories : Python

matlab function "adapthisteq(image)" equivalent in c#
This is C code, but it's what every CLAHE algorithm is based on: CLAHE GraphicsGems. If you can use the OpenCV library and NVidia GPUs, you could use: OpenCV CLAHE. Or even OpenCV CLAHE Interface (without GPU). From Toby Breckon.

Categories : C#

What is the easiest method to implement(draw) 3d plot/scatter, the equivalent of plot3 from matlab?
ILNumerics is quite easy to learn. It combines a mathematical engine with visualization capabilities (providing Windows Forms Controls). I've posted an example here: Creating a 3D Scatter Plot in C#

Categories : C#

Java equivalent to Matlab's `eps` or Numpy/Python's `spacing` function (floating-point relative accuracy)
You want java.lang.math.ulp: Returns the size of an ulp of the argument. An ulp of a double value is the positive distance between this floating-point value and the double value next larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x) Also, available for floats. Some background on ULPs.

Categories : Java

Is there a C++ equivalent (or equivalent technique) of Perl's __DATA__ segment?
There’s nothing like that in general. However, the Linux ELF binary format allows the inclusion of data files via the GNU tool objcopy. On Windows you can use resource files and assign the linker to include those in the executable. OS X conventionally uses application bundles to achieve a similar effect.

Categories : C++

Equivalent of "GoTo" in Google Apps Script (equivalent VBA-GAS )
You don't need GoTo, most people would argue that it is terrible programming practice to use it even when it is present. Using other control structures will do the job. if() { } else if() { } else { } for(;;) { continue; break; } while() { } do { } while(); switch() { case: default: } // for errors throw "Error string" try { } catch(error) { } You'll have to shuffle your logic around a bit, but it will result is better more maintainable code.

Categories : Javascript

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

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

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: 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

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-->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

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#

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++

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

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

Converting MATLAB 'imagesc' function to work with R's 'imagesc' from R's 'matlab' library
As I read the question and the linked material and some other material found with Google, you want the combined capacities of the image and axis functions in R. Some of the other material said that imagesc really only relabels the axis annotation. (And it has some additional color scaling capacity that you don't seem to be requesting.) Reading images in from files may take some extra packages. There is a grImport package with useful capabilities for pdf. There are also packages that specialize in particular formats, eg. tiff or rtiff. If you have a modes sized matrix to plot, you should offer dput(mat). In the absence of an example and specific directions can offer this adaptation of an example in the middle of the Examples section of ?image. > image(t(volcano)[ncol(volcano):1,]) #

Categories : R

TFS equivalent of "hg cat"?
TFS needs a workspace to have a mapping between the server repository and your local machine. If you already defined a workspace that includes $/dev/components/log.zip, then switch to that folder in the command line tool. If you want to get the file to the folder where you are at the moment, you need to create a new workspace. This can be done in Team Explorer or by using tf.exe: tf workspace /new logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection Now you have a workspace, but you need to map the server path to the local folder: tf workfold /map $/dev/components . /collection:http://tfsserver:8080/tfs/DefaultCollection /workspace:logZipWs Now your command should work. But the creation of workspaces is much easier using the Team Explorer. When you're done, make sure yo

Categories : Tfs

equivalent tr of CSS?
The clear property will do this for you. You can add it to your #container for example: #container { display: table; clear:both; } Clear means something like: clear all elements on both sides of this element

Categories : CSS

d3.js equivalent to $(this)
It turns out d3.select(this) is the correct answer. Code now is : var buttons = svg.selectAll(".button"); buttons.on("click",function(d){ var target = $(this).attr('target'); var visible = $(this).attr('visible'); if(visible==='1'){ svg.selectAll(".bar."+target).transition().duration(500).ease("elastic").style('display','none'); d3.select(this).attr('visible','0').style('text-decoration','line-through'); }else{ svg.selectAll(".bar."+target).transition().duration(500).ease("elastic").style('display','inline'); d3.select(this).attr('visible','1').style('text-decoration',''); } });

Categories : Jquery

Vb.net equivalent of C#
Simple convertion should do it : Dim model = New PlotModel("MouseDown HitTestResult", "Reports the index of the nearest point.") Dim s1 = New LineSeries() s1.Points.Add(New DataPoint(0, 10)) s1.Points.Add(New DataPoint(10, 40)) s1.Points.Add(New DataPoint(40, 20)) s1.Points.Add(New DataPoint(60, 30)) model.Series.Add(s1) s1.MouseDown += Function(s, e) model.Subtitle = "Index of nearest point in LineSeries: " & Math.Round(e.HitTestResult.Index) model.InvalidatePlot(False) End Function Sources : http://www.developerfusion.com/tools/convert/csharp-to-vb/

Categories : C#

What is the equivalent CSS in IE7?
Although you mention not wanting to use an IE7 hack, here is a valid way of creating IE7 only styles without adding additional style sheets, this will solve your problem, add the following code <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if !(IE 7)]><!--> <html> <!--<![endif]--> in place of your usual html tag. You can then use: .ie7 .css-selector { to target any element in ie7 only. For full disclosure, this works for all versions of ie if you use conditional comments such as: <!--[if lt IE 7 ]> <html class="ie6"> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![endif]--> <!--[if IE 9 ]> <html cla

Categories : HTML

JS equivalent to C++ .at()
You can use the in operator: if("bar2" in foo) { //do stuff with foo['bar2'] } or you can check to see if foo['bar2'] is undefined: if(typeof foo['bar2'] !== "undefined") { //do stuff with foo['bar2'] } Also, what you're working with are objects and not arrays (well, they're associative arrays, but also objects in JavaScript).

Categories : Javascript

Is e1 && e2 equivalent to e2 && e1?
Logically, yes. e1 && e2 will never have a different result than e2 && e1 from a logical standpoint. But from a code standpoint, if evaluation of e1 or e2 has side effects, then no, they are not completely equivalent. Specifically, sometimes people use functions in a chain of &&. if( isHungry() && hasFood() ) eat() ; Usually you would want to put the cheapest to evaluation condition first, and only check the 2nd condition if the first condition held up as true. Short circuit evaluation is what guarantees this will happen. If the 1st condition in an AND logical operation is false, then the 2nd statement isn't even evaluated, because the end result won't be TRUE anyway (FALSE && (TRUE && TRUE && TRUE && TRUE)) == FALSE

Categories : C

VB Equivalent of "To" in C#
I think what you're looking for is this: System.Array.Resize(ref indexCorr, fDefMatchs.Length); However, in .NET you cannot set the lower bound of an array. From the documentation: Arrays are zero indexed: an array with n elements is indexed from 0 to n-1.

Categories : C#

Equivalent of "this" keyword in vb.net
Take a look at this MSDN article on VB extension Methods. Applying it will lead to something like this. Imports System.Runtime.CompilerServices Imports System.Text.RegularExpressions Module Module1 Sub Main() Dim myString As String myString = "1955" Console.WriteLine(myString & " is Year =" & myString.IsYear) myString = "3955" Console.WriteLine(myString & " is Year =" & myString.IsYear) myString = "19555" Console.WriteLine(myString & " is Year =" & myString.IsYear) Console.ReadLine() End Sub End Module Module Extensions <Extension()> Public Function IsYear(ByVal data As String) As Boolean Return data.Length = 4 And Regex.IsMatch(data, "[12]+[0-9]+[0-9]+[0-9]") End

Categories : Vb.Net

Is there a vim equivalent to bash's '!$'?
Using :vsp with no arguments splits the current window. Not exactly what you're asking for, but I often use % which is the current filename: :e some_file :vsp % See :help cmdline-special

Categories : Bash



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