w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Keeping Some MATLAB Function Input Arguments Inactive
There are a number of ways of doing this. A simple alternative to varargin is to pass a logical vector with 0/1 values. In your case, the vector would contain 11 entries. The value of each entry would signal to the function whether to expect that variable pair in a separate array. Within the function you could have a series of if statements to check whether an entry in v is 1 or 0, for instance: function [myoutputs] = myfunction(array_1,array_2,...., v); default_1 = some_values1; % change some_values1 to whatever should be defaults for variable 2 default_2 = some_values2; % change some_values2 to whatever should be defaults for variable 2 % ... additional default initializations if v(1) pair_1 = array_1; else pair_1 = default_1; end % ... if statements for remaining pairs...

Categories : Matlab

Matlab Undefined function or method 'C' for input arguments of type 'double'
You've to do either of following a) pass C as argument to function simps() OR b) evaluate C from workspace C = evalin( 'base', 'C' ); inside the function before its use. Also, use of eval and evalin is generally discouraged as it makes your code harder to follow and re-use. Tip : You may want to combine both like following function simps(C) if nargin == 0 C= evalin( 'base', 'C' ); end % Your code

Categories : Matlab

Best way of calling a function with different arguments passed by reference when you only need one of these arguments
Acknowledge to Mats Petersson: you can't pass nullptr as the function requires references. If the function has no warranty attached to it, then you should create temporary variables and pass them all in. It would be unsafe to pass the same variable; in case it's used in internal computation. Even if the function works with the same variable passed, there is no guarantee that someone won't change the implementation of that function in a way that causes your code to break. You could be opening yourself up to nasty bugs in the future.

Categories : C++

sprintf function's arguments and formats in matlab
You are providing sprintf more arguments than there are %s in the format string. Therefore, sprintf re-uses the format string from begining: sprintf('%05d%s%02d%s%02d',546,'.',1,'.',3,4,56) result: 00546.01.03000048 ^ starting fromat anew printing 00004 for %05d with 4 The final '8' character is 56 printed as '%s' (if you want to check it out the ascii code of '8' (the char) is 56!)

Categories : Matlab

Calling a custom emacs function with arguments
You would need to use special form interactive for reading arguments. Something like this untested code: (defun forward-xdvi-search (line-number) (interactive "nForward to line: ") (shell-command (format "bash -ic %s" (shell-quote-argument (format "latex -src J[HCI]*.tex; for i in J[HCI]*.dvi; do xdvi -sourceposition "%d ${i/.dvi/.tex}" $i; done ;" line-number))))) Edited with the improvement suggested by @phils

Categories : Shell

Calling a function in JS doesn't work with arguments
You need to wrap that call in an anonymous function: req.onreadystatechange = function() { handleResponse(username, game_id); <--- THIS IS THE CALL }; The code you posted will call that handler at the point the assignment is made. Instead of that, you need to assign a function that will be called when the ready state changes.

Categories : Javascript

when javascript function alter html input text ,I want the input text trigger a event like calling other JS function
You can call it yourself. var counter = 0; function AlterText(){ counter=counter +1; document.getElementById('txtbox1').value = counter; AlertMe.call(document.getElementById('txtbox1')); } function AlertMe(){ alert("Done!.."); }

Categories : Javascript

Calling scanf() after another string input function creates phantom input
It because the scanf call reads a character, but leaves the newline in the buffer. So when you next time call fgets is finds that one newline character and reads it resulting in an empty line being read. The solution is deceptively simple: Put a space after the format in the scanf call: scanf("%s ", choice); /* ^ */ /* | */ /* Note space */ This will cause scanf to read and discard all training whitespace, including newlines.

Categories : C

Undefined function 'time' for input arguments of type 'double'. How do i find a function that others didn't seem to have defined in their code?
As pm89 already suspected, time in this case is a variable. Type: > help mpretrack in your command window. Amongst other information, it will say: Also, the program looks for the files "fov#times.mat" for the "time" variable and the images files "fov#fov#####.tif" from the basepath. If you don't have the specified .mat file, the variable time is unknown, which causes the error you see.

Categories : Matlab

Calling MATLAB function "imread" from MEX
In Matlab MEX the behaviour of strings differs in different versions. In current versions I think that strings are represented as 16-bit Strings (UNICODE) instead of ASCII. The size of the character array must be exactly as long as the length of the string not containing a terminating NUL (this is true for all MATLAB versions). To avoid problems you should use the special C-string-to-mxArray function (I think it is named mxCreateString or so). By the way: "string" and "img" are of the type "mxArray *", not of the type "mxChar *". The second argument of mexCallMATLAB must be a pointer to "img", not "img" itself!

Categories : C

Invalid number of arguments when calling static method through function reference
Okay, found the issue. I was linking some of this swfs library with another, that other swf used the ProductInfoManager, so instead of compiling the newer version of ProductInfoManager with changes, flash was pulling the old version from the other swf. Quite frustrating behaviour if you don't know what's going on.

Categories : Actionscript

How do I put a folder as an input in a matlab function?
If you want each row in a to have a string and two numbers, it should be a cell array: ... a=[] for i ... ... a{i}={files{i} u q}; end ... To get to the filenames you do a{1}{1} ans= file1.jpg To get to the numbers you do a{1}{2},a{1}{3} (to get std and mean of file1.jpg, resp.) Another way to do it is to make a a struct array.

Categories : Matlab

matlab function for sum of n number of input?
If you want to have a function that takes several scalar inputs and give you their sum, then do the following: function result = sum_var(varargin) result = sum(cell2mat(varargin)); end The problem you have is that varargin is a cell array and you have to transform it to a matrix array (using cell2mat()) before using the sum() function on it.

Categories : Matlab

cannot read input while calling from function
Your line then in="yes" | input is the issue. You don't want to pipe the assignment of in into input. Separate the commands with a semicolon or a newline: then in="yes"; input

Categories : Linux

MATLAB: how to make my function wait for GUI input
Try using a pre-defined question dialogbox. See here for more details. button = questdlg('How many players?', 'One', 'Two' );

Categories : Matlab

Matlab: Return input value with the highest output from a custom function
What you described is a good way to do it. outcomeVec = myfunc(myVec); [~,ndx] = max(outcomeVec); myVec(ndx) % input that produces max output Another option is to do it with a loop. This saves a little memory, but may be slower. maxOutputValue = -Inf; maxOutputNdx = NaN; for ndx = 1:length(myVec) output = myfunc(myVec(ndx)); if output > maxOutputValue maxOutputValue = output; maxOutputNdx = ndx; end end myVec(maxOutputNdx) % input that produces max output Those are pretty much your only options. You could make it fancy by writing a general purpose function that takes in a function handle and an input array. That method would implement one of the techniques above and return the input value that produces the largest output.

Categories : Arrays

Calling functions inside functions when the inner function's arguments will always be the same as the outer's
I honestly think your first technique is the best way to go and perfectly idiomatic. Still, here's another option: def outer_method(word) inner_lambda = lambda do puts "I really love " + word + "!" end inner_lambda.call puts word + " tastes like candy." end outer_method("onions") lambda creates a lexical closure, which means it captures the surrounding environment, including the reference to word.

Categories : Ruby

Dynamic generated input button not calling function everytime
try this: function shiftRight(leftButtonNo) { //Creating a hidden field in the form if(!$("#innerQuestionListDiv" + leftButtonNo).doesExist()) { if(!$("#clonedDiv"+leftButtonNo).doesExist()) { var button = $('<input type="hidden" name="questionIdsForTestSet" value="'+ leftButtonNo+'" id="questionIdForTestSet'+ leftButtonNo+'" />'); $('#TestSetFormId').append(button); var $cloneQuestionDiv = $("#div"+leftButtonNo).clone(), $list = $("#list"+leftButtonNo); var $shiftLeftButton = (function(leftButtonNo, button, $cloneQuestionDiv, $list) { var newButton = $('<input/>').attr({ type: 'button', name:'shiftLeft',

Categories : Javascript

Transformation 2 input 2 output transfer function into state space model using MATLAB
Converting to a SS model is always an ugly process, and depending on the method you can get different representation. So don't obsess over getting equal values of A B C and D. Also, the states of SS that have been converted from TF often have no meaning other the storing information of the previous state. To verify whether you have similar SS system, throw in an impulse response: impulse (sys, sysSimulink) From the documentation: Recommended Working Representation You can represent numeric system components using any model type. However, Numeric LTI model types are not equally well-suited for numerical computations. In general, it is recommended that you work with state-space (ss) or frequency response data (frd) models, for the following reasons: The accuracy of

Categories : Matlab

cx_Oracle gives OCI-22062 invalid input string when calling function with bool parameter
I had to find a workaround for this problem, because I couldn't find a way to make the callfunc work as it should. In this workaround I use one temporary table that was created for some other purpose, but it's just what I need. I changed callfunc to execute and made it like this: self.cursor.execute(""" declare result number; begin result := pkg_planista.zatwierdz_plan(:pid, :alg = 1); INSERT INTO tmp_dz_v_planista_pracownicy values (result); end; """, {'pid': pl_id, 'alg': int(new_algorithm)}) ret = self.cursor.execute("SELECT * FROM tmp_dz_v_planista_pracownicy") This way I can call the function and receive it's return value. The tmp_dz_v_planista_pracownicy table is just a temporary table with one column of type NUMBER.

Categories : Python

Calling function onClick of label that is bound to input type radio using 'for' attribute in mobile devices
label does not have id 1 so your selector is wrong, you need to bind the handlers to label with for attribute value 1 $("#1").unbind("click"); $("label[for=1]").on('swipe', function(){ });

Categories : Jquery

Function Arguments dialog executes UDF when all non-optional arguments are filled
From my UDF page: Excel User-defined Functions To detect when a VBA UDf is being called from the function wizard you can add this code to the UDF If (Not Application.CommandBars("Standard").Controls(1).Enabled) Then Exit Function This code depends on the fact that when using the function wizard most icons in the toolbars are disabled. A solution is also possible by using the Windows API to check if the Function Wizard window is showing and has the same process ID as the current Excel process.

Categories : Excel

too few arguments to function even when arguments count are correct
Try and keep it simple. If the "complex" problem is failing, try a simpler approach, i.e. /* Since this doesn't work, let's try something that really should work fun_sbblink_write_OP_frame_channels (0,SBBL_FLINK,PhSlotRRH,i,0,0,0,0); */ sbblink_write_one_frame(1,2,3,4,5,6,7,8); Then, if that works try: /* Since this doesn't work, let's try something that really should work fun_sbblink_write_OP_frame_channels (0,SBBL_FLINK,PhSlotRRH,i,0,0,0,0); */ /* OK, this worked, let's go one step forward sbblink_write_one_frame(1,2,3,4,5,6,7,8); */ fun_sbblink_write_OP_frame_channels (1,2,3,4,5,6,7,8); Then try: /* OK, this silly stuff worked, let's go all the way sbblink_write_one_frame(1,2,3,4,5,6,7,8); fun_sbblink_write_OP_frame_channels (1,2,3,4,5,6,7,8); */ fun_sbblink_write_OP_fra

Categories : C

Oracle Calling a job with arguments
You should first create the job, then define the arguments, and then run it. When you create it, set the enabled atribute to false, so it won't run yet: dbms_scheduler.create_job(job_name => 'parse_job', program_name => 'PARSE_PROGRAM', start_date => systimestamp, enabled => false ); Then pass the arguments to the job: dbms_scheduler.set_job_argument_value(job_name => 'parse_job', argument_position => 1, argument_value => 1); Then enable it with a call: dbms_scheduler.enable('parse_job');

Categories : Oracle

Calling delegates without arguments in VB.NET
I'm guessing here, so please give it a try: Instead of: For Each t As ProcessThread In p.Threads EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero) Next Try: For Each t As ProcessThread In p.Threads Dim returnMyEnumThreadWindowsProc As Object returnMyEnumThreadWindowsProc = MyEnumThreadWindowsProc ( ... ) EnumThreadWindows(t.Id, returnMyEnumThreadWindowsProc , IntPtr.Zero) Next I know that VB.NET doesn't do anonymous functions like C# does, but I am not sure how the alternative works.

Categories : C#

Calling a method with arguments after certain time
You can try GCD's dispatch_after. For instance: dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ [self myMethod:someValue setValue2: someValue2]; });

Categories : IOS

Calling Java from PHP with arguments as arrays
There is no direct mapping between an array-like data structure in PHP and Java. If possible, you could convert the PHP array to a serialized Java object array / ArrayList, etc., but such a library may either not exist or would have to be installed and included. Instead it would be much easier to use JSON. $var2 = json_encode($var2); Unfortunately, Java has no native JSON support. Two popular Java libraries for JSON are Jackson and Gson. They are both able to easily parse JSON strings into Java data structures. If all you want is a string representation of the array items, you could do implode(',', $var2)

Categories : Java

Get calling arguments for getter in javascript
You can't see what the property gen will be used for in the future, so you would need to return an object with properties that react to what the object is used for when it actually happens: var myThing = {}; Object.defineProperty(myThing, 'gen', { 'get' : function() { var no = {}; Object.defineProperty(no, 'cool', { get: function(){ alert('cool'); } }); Object.defineProperty(no, 'neat', { get: function(){ alert('neat'); } }); return { oh: no }; } }); Demo: http://jsfiddle.net/UjpGZ/1/

Categories : Javascript

Calling a cmdlet with custom arguments
Using parameter validation: Function Foo { Param( [ValidateRange(1,31)] [String] $day , [ValidateRange(1900,2013)] [Int] $Year , [ValidateRange(1,12)] [string] $Month ) Process { Get-Date -Day $day -Year $year -Month $month } } Read here and here to learn improve the validation

Categories : Powershell

How to pass arguments when calling `source` command
There are 3 predefined variables: $argc - number items of arguments passed to a script. $argv - list of the arguments. $argv0 - name of the script. So in your case, assuming the file sourced is in the same directory and its name is passed as a first argument: source [lindex $argv 0]

Categories : C++

Calling superclass constructors in python with different arguments
You didn't pass self. class AB(A, B): def __init__(self, x, y, z=0): A.__init__(self, x, y) B.__init__(self, z) Note that if this inheritance hierarchy gets more complicated, you'll run into problems with constructors not executing or getting reexecuted. Look into super (and the problems with super), and don't forget to inherit from object if you're on 2.x and your class doesn't inherit from anything else.

Categories : Python

Calling multiple arguments from objective-c to applescript-objc
For starters, IBActions must have a signature of: -(void)action; -(void)actionWithSender:(id)sender; -(void)actionWithSender:(id)sender event:(UIEvent*)event; So you can't have an IBAction with multiple arguments if that's what you were looking for. However, to answer your question, to have a method with multiple arguments, in Objective-C, it would look like this: - say:(NSString *)textToSay withUserName:(NSString *)userName { ... } In AppleScriptObjC, you move all of your Objective-C method parameters to the beginning of the method name, replace the colons with underscores, and put your arguments in the parentheses. on say_withUserName_(textToSay, userName) ... end say_withUserName_

Categories : Objective C

wrong number of arguments calling `request` (0 for 1) (ArgumentError)
The request.session object is really just a hash and delete(doc) expects 1 parameter(the key you want to delete delete). Here is what your step definition should look like: Given "an unauthenticated visitor" do Capybara.reset_sessions! end

Categories : Ruby On Rails

Wrong number of arguments when calling .all on record which has enum_attr
Seems you are using Rails 4 which from the release notes: Model.all now returns an ActiveRecord::Relation, rather than an array of records. Use Relation#to_a if you really want an array. In some specific cases, this may cause breakage when upgrading. So for starters you would want to call to_a on the model. But are you sure enumerated_attribute is rails 4 ready? If you're not using postres I would recommend just using validates_inclusion_of, if you're using postgres check out https://coderwall.com/p/azi3ka

Categories : Ruby On Rails

How to work around NSTask calling -[NSString fileSystemRepresentation] for arguments
A possible solution would be to subclass NSString and provide your own implementation of -fileSystemRepresentation, but unfortunately NSString is a class cluster and thus very difficult to subclass (which is also discouraged by Apple's documentation). However, we can create a separate class that poses as an NSString, but provides its own implementation of -fileSystemRepresentation. This can, however, create problems if NSTask does anything with the class identity of the argument objects. Currently I have no evidence that this is the case — this workaround seems to work perfectly. Header: // MYTaskArgument.h @interface MYTaskArgument : NSObject + (instancetype) taskArgumentWithString:(NSString *)str; @end Implementation: // MYTaskArgument.m @interface MYTaskArgument () @property(

Categories : Objective C

Calling R from Matlab
Unset environment variable DYLD_LIBRARY_PATH before calling R script: >> !/usr/bin/Rscript ms.R Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so': dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4 Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64/libgfortran.2.dylib in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib During startup - Warning message: package 'stats' in options("defaultPackages") was not found Error: could not find function "rnorm" Exe

Categories : R

Calling Matlab from VB
You have two main options. MATLAB has a COM interface. From VB, you can start an instance of MATLAB, pass data to it, execute commands, retrieve results, and quit MATLAB. To find out more, take a look at the documentation pages for the MATLAB COM Automation Server. This method will require you to have a live copy of MATLAB present when you run your VB application. You can use an add-on product to MATLAB, MATLAB Builder NE for .NET (you'll also require another add-on that it depends on, MATLAB Compiler). MATLAB Builder NE allows you to convert your MATLAB code into a standalone .NET assembly or COM component that can be called from your VB application, and distributed with it. Note that contrary to a comment, MATLAB Compiler alone without MATLAB Builder NE does not allow you to produce

Categories : Vb.Net

calling R from within Matlab
This is probably caused by a version mismatch between libraries used by MATLAB and R. You might be able to fix this by using LD_PRELOAD. Use ldd inside and outside MATLAB to figure out whats causing the problem... In MATLAB: >> !ldd Rscript In the shell: $ ldd Rscript btw the Linux equivalent to the existing solution would be: >> !unset LD_LIBRARY_PATH >> system('...') so try that out first.. (Note that I am on a Windows machine, so neither solutions are tested)

Categories : Linux

Calling C++ .dll libraries from MATLAB
The include file 'USBCommAdapter.h' should be in the search path of Matlab. An easy way is to put it in current working directory. Input path command in Matlab to check if USBCommAdapter.h is in it.

Categories : C++

Calling Java method from JRuby throws "no constructor for arguments error"
JRuby can not always guess "complicated" method args for you, you might want to try : Jacop::Knapsack.new(@values, @weights, quantity.to_java(JaCoP.core.IntVar), knapsackCapacity, knapsackProfit) or even helping with the int[] cast (should not be necessary) : Jacop::Knapsack.new(@values.to_java(:int), @weights.to_java(:int), quantity.to_java(JaCoP.core.IntVar), knapsackCapacity, knapsackProfit)

Categories : Java



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