w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
handling dataset array as dataset in matlab like as other programs(spss,r,stata)
b = datasetfun(fun,A) applies the function specified by fun to each variable (each column) of the dataset array A. As factoran needs more than one column to perform its opertaions, it can't be used with datasetfun.

Categories : Matlab

Update TableAdapter with DataSet - Update requires a valid DeleteCommand error
It means that you are using a DataAdapter to update a table which contains deleted DataRows (their RowState is Deleted). Then the DataAdapter uses the specified DeleteCommand to delete this row in the database. But you haven't provided it. So you need to provide it. MSDN example: public static SqlDataAdapter CreateCustomerAdapter( SqlConnection connection) { SqlDataAdapter adapter = new SqlDataAdapter(); // Create the SelectCommand. SqlCommand command = new SqlCommand("SELECT * FROM Customers " + "WHERE Country = @Country AND City = @City", connection); // Add the parameters for the SelectCommand. command.Parameters.Add("@Country", SqlDbType.NVarChar, 15); command.Parameters.Add("@City", SqlDbType.NVarChar, 15); adapter.SelectCommand = comm

Categories : C#

Dataset in Matlab
Assuming cds is a string, it can be used as a dynamic field name: cdslist = universe.Bond; cdscount = length(universe.Bond); spread = struct; for i = 1:cdscount cds = cdslist{i}; spread.(cds) = data; end

Categories : Matlab

Creating dataset from matrix in Matlab
Have you considered using a struct? I use these all the time in MATLAB for database things, I know it works absolutely fantastic for up to 20,000 elements with about 15 fields each, so I think it would still work just as well as anything else for 2 million items with 2 fields. Alternatively, can't you just put it in a cell array? DataBase{rowNum,1}=dataVector(rowNum,:); DataBase{rowNum,2}=label{rowNum}; To preallocate a struct or cell, its relatively easy, with a struct, once you make your first one to initialize the fields, just say Struct(2000000).fieldName =[] TO preallocate your cell array, just do DataBase={[]} DataBase{2000000,2}=[] This preallocates all of it and fills it with empty values.

Categories : Matlab

How to generate a 'clusterable' dataset in MATLAB
It very much depends on what kind of dataset you expect - 1D, 2D, 3D, normal distribution, sparse, etc? And how big is "big"? Thousands, millions, billions of observations? Anyway, my general approach to creating easy-to-identify clusters is concatenating sequential vectors of random numbers with different offsets and spreads: DataSet = [5*randn(1000,1);20+3*randn(1,1000);120+25*randn(1,1000)]; Groups = [1*ones(1000,1);2*ones(1000,1);3*ones(1000,1)]; This can be extended to N features by using e.g. randn(1000,5) or concatenating horizontally DataSet1 = [5*randn(1000,1);20+3*randn(1,1000);120+25*randn(1,1000)]; DataSet2 = [-100+7*randn(1000,1);1+0.1*randn(1,1000);20+3*randn(1,1000)]; DataSet = [DataSet1 DataSet2]; and so on. randn also takes multidimensional inputs like randn(

Categories : Matlab

Matlab: Sort a dataset according to a vector
Try something like this: % Preparation A = your_column_vector; B = your_data_matrix; C = [A; B]; % Calculation D = sortrows(C, 1) % Clean up your_sorted_matrix = D(:, 2:end)

Categories : Matlab

k_means algorithm for an image dataset in matlab
Wikipedia has a good article on the technique of k-means clustering. Procedurally, you identify a set of items that can be expressed as vectors--- in your case, I think the items are image frames and the vector components are the values of all the pixels in the frame (thousand or million dimensional vectors). K-means clustering finds k groups of image frames that are similar within each group and dissimilar between groups. You decide what k is: 5 or 10 or whatever. First step: randomly define k points in the million-dimensional vector space. It sounds like you did that. Second step: for each image frame, find out which of the k points is closest to the frame in question, using Euclidean distance. It doesn't sound like you did that, but I don't know. Third step: for each of the k gr

Categories : Matlab

Update Database from Dataset
I am thinking your problem are these lines: "UPDATE Inventory SET qty = @qty" + "WHERE sku = @sku", connection); They are going to produce a string like: "UPDATE Inventory SET qty = @qtyWHERE sku = @sku", connection); And the variable @qtyWHERE is not defined. Try this instead: "UPDATE Inventory SET qty = @qty WHERE sku = @sku", connection);

Categories : C#

Update row in SQLite without all information from the dataset
Why not using Update()? It seems that the _id is your table's primary key. If your intention is just to update a record when you already have the primary key then it should be pretty simple: String whereClause = "_id=" + getId(); ContentValues cv = new ContentValues(); cv.put("ISBN", isbn); //update(String table,ContentValue value, String whereClause, String[] whereArgs) db.update("tbl_Book", cv, whereClause, null); As far as I know (maybe I'm wrong), Replace() will first delete a row if it exists and then inserts a new record based on provided values. In your case I think, it deletes the corresponding record (based on the id) and then try to insert new one: For instance let's say the _id is 1: +-----+-------+---------+-------+------+ | _id | Title | Author | Pages | ISBN | +-----+-

Categories : Android

Dataset Update without Locking SQL Server 40,000+ Rows
An UPDATE in a SQL Server will always have to take an exclusive lock - no way / no trick / no hack around this. But this exclusive lock is just on the single row that's being updated - and it will be released after the transaction is done. However: if you update more than 5000 rows in single transaction, SQL Server will escalate the row-level exclusive locks to a table-level lock - essentially locking the entire table until the transaction is completed. I see two options here: if you can live with this approach, you could break up your import into chunks of e.g. 2000 rows in a single transaction; this way, you could avoid the table-level exclusive locks, and your system would remain more responsive during import. The downside would be: it might take a bit longer, and you might end up

Categories : Sql Server

Get the values from dataset in vb.net
You can try like this: For i As Integer = 0 To ds.Tables(0).Rows.Count - 1 Dim someVar As Integer = Integer.parse(ds.Tables(0).Rows(i)(0).toString()) Next You can use online converter to resolve this issue.

Categories : Asp Net

How can I update the dataset in my vb.net 2012 report after changing a table structure?
To refresh the fields for a specific dataset In the Report Data pane, right-click the dataset, and then click Dataset Properties. Note: If the Report Data pane is not visible, on the View menu, click Report Data. If the pane opens as a floating window, you can dock it. In the Query pane, type the query. Click Refresh Fields. Click OK. In the Report Data pane, expand the dataset node to view the currently defined field collection. Ref: http://msdn.microsoft.com/en-us/library/ms365160(v=sql.100).aspx

Categories : Visual Studio 2012

Use JSON with jQuery and dataset(how to loop the values)
Perhaps like this (second example) $(function() { var $widget=$("#widget"); $.get($widget.data("load"),function(data) { $.each(data.something,function(key, value) { $widget.append(value); }); });

Categories : Javascript

Returning dataset values giving an error
public DataSet GetFunc() { int iRet = 0; DataSet ds = new DataSet(); SqlConnection sqlConnection = new SqlConnection(); try { iRet = connect(ref sqlConnection); if (DB_SUCCESS_CONNECT == iRet) { SqlCommand sqlCommand = new SqlCommand("", sqlConnection); String strQuery = "Select ID, Did, FirstName from Users"; sqlCommand.CommandText = strQuery; SqlDataAdapter adaptor = new SqlDataAdapter(sqlCommand); adaptor.Fill(ds); sqlConnection.Close(); return ds; } } catch (Exception e) { disconnect(ref sqlConnection); } return null; } Not all paths of your code return value, but have to. If DB_SUC

Categories : C#

How to transform a dataset's mean and standard deviation with different values per column in R
You can use scale and sweep: sample <- scale(as.matrix(sample),TRUE,TRUE) sample <- sweep(sample,2,sdevs,"*") sample <- sweep(sample,2,means,"+")

Categories : R

In R, find duplicated dates in a dataset and replace their associated values with their mean
Here's a solution that doesn't bother to actually check if the id's are duplicated- you don't actually need to, since for non-duplicated id's, you can just use the mean of the single var value: duplicated_ids = unique(z$id[duplicated(z$id)]) library(plyr) z_deduped = ddply( z, .(id), function(df_section) { res_df = data.frame(id=df_section$id[1], var=mean(df_section$var)) } ) Output: > z_deduped id var 1 1 3 2 2 2 3 3 5 4 4 2

Categories : R

Matlab: Referring to dataset column with a variable containing the column name
Use parentheses for dynamic field names: dataset.(variableName)

Categories : Matlab

Perform count on similar values in using Pig for multiple line of dataset
Assuming email and websites are tab separated and websites themselves are space separated. Following is step by step code to get desired output, the main idea is to first tokenize the websites, flatten them, do group by (email, tokenize_website), generate count, then do a group by email. A = LOAD 'sample.txt' AS (email:chararray, urls:chararray); B = FOREACH A GENERATE email AS email, FLATTEN(TOKENIZE(urls)) AS tokenize_urls; Dumping B e1 web1 e1 web2 e1 web3 e1 web1 e2 web2 e2 web3 ...... Now grouping by (email, tokenized urls) and generating count C = GROUP B BY (email, tokenize_urls); D = FOREACH C GENERATE group.email as email, group.tokenize_urls as url, COUNT(B) as url_count; Dumping D e1 web1 2 e1 web2 1 e1 web3 1 e2 web2 3 .... N

Categories : Hadoop

Matlab reading hex values from text file with non hex values interspersed?
This solution reads 1 million 2-character lines in less than a second on my laptop: fid = fopen('test.txt'); A = textscan(fid,'%2c','CommentStyle','XX'); fclose(fid); A = hex2dec(A{:}); Note the 'CommentStyle' option that skips those lines that start with XX.

Categories : Matlab

How to display static values after report result in SSRS 2008 having two DataSet
You just need to add a Table Footer row (or rows) and enter your required values there. For example: In the designer this is just a simple table with one Header row, one Detail row and two Footer rows. When run the report looks like this: i.e. all rows in result set are displayed, then a couple of rows of static data. Edit after comment As per the comment there is a mix of DataSets involved, too. For getting fields from another DataSet into the table, you can use an expression like: =First(Fields!static1.Value, "DataSet2") This specifies that the field is in a different Scope, i.e. DataSet2. You need to use First as there has to be some sort of aggregate expression in these cases; if your static data DataSet has only one row you could just as easily use another but First makes

Categories : Reporting Services

Clone dataset > Change column type > Populate dataset
assuming you have only one table in the data set, you can do something like this. int ColumnIndex = 0; //Column index of your data you want to copy for (int i = 0; i < dataset_original.Tables[0].Rows.Count; i++) { dataset_cloned.Tables[0].Rows[i].SetField(ColumnIndex, dataset_original.Tables[0].Rows[ColumnIndex].ItemArray[0].ToString()); } in the same for loop you can copy remaining columns data

Categories : Asp Net

Does each assignment of values to an output NetCDF variable result in a rewrite of the entire dataset?
I use NetCDF4-Python for reading/writing NetCDF, and no, the whole file is not written when you write a variable, or chunk of a variable. Here's a full example: http://nbviewer.ipython.org/5764942

Categories : Python

Javascript - dataset too large, need to only include data up to 1000 values that's spaced out evenly
You could try something like this (in pseudo-code): var desired_data_length = 1000; for (var i = 0; i < desired_data_length; i++) { var actual_i = int(float(i) / float(desired_data_length) * float(chartdata.length)); // do something with actual_i as the index } This will use desired_data_length number of indices, and will linearly interpolate from [0,desired_data_length) to [0,chartdata.length), which is what you want.

Categories : Javascript

Dataset Tables Merging in single dataset with result set
Could you not use the DataTable.Merge method? Start with a clone of the first table and then merge in the data from the other tables? The Merge method has an option, MissingSchemaAction, that lets you specify that new columns should be added to the resulting table so it should do what you are after.

Categories : Asp Net

How to create a BIRT dataset that accepts multiple (CSV) values that it can be used inside "IN" clause in select statement
We cannot do this with a regular SQL parameter '?'. A workaround is to replace this '?' by a default value in the query, and dynamically inject an appropriate comma-separated list of values in the "beforeOpen" script of the dataset: Default query Assuming the datatype of ID is an integer, set up the query like this (of course use here a valid ID to be able to preview data): select * from table where ID in ( 1000 ) "beforeOpen" script of the dataset: this.queryText=this.queryText.replaceAll('1000',params["parameter_name"].value.join(",")); This way, if "parameter_name" returns 3 values 1100,1200,1300 the query sent to the database will be: select * from table where ID in ( 1100,1200,1300) It is similar if the datatype of ID is a String, we just have to play a little bit wit

Categories : Reporting Services

SSAS (MDX) - Filtering Dataset based on another Dataset
If the result sets are not huge, the easy way is to do this is with a filter on the Dataset and NOT in MDX: Add a Boolean filter in which the Expression is =True and the Value is something like this: =iif(instr(join(Parameters!DataSet2Parameter.Value,","), Fields!ToDimDateHierarchy.Value)=0,True, False)

Categories : Reporting Services

Update ODE variables in Matlab
There are two ways of doing this. Either way you need to understand that you cannot just set x(4) to 1 and hope everything works out for the best. Matlab won't care about the preceding values of x(4) as they are all stored in memory. Furthermore, the upcoming value of x(4) is determined by dx(4) and the previously retained values of x(4) (which you cannot set). You have two possible solutions to your problem: A) set dx(4) = 0 when your condition is met if x(4) > 1 dx(4) = 0; else dx(4) = a41 * x(1) - a42 * x(4) + b4 * u4; end This however will not result in a perfect x(4) = 1, rather there will be a small error. B) Calling an event function, which can be learned about here and here, in which case you can interrupt for a new function call.

Categories : Matlab

how to update a variable in matlab?
As far as I know, this can't be done automatically in MATLAB. I would create a script that does all the updating, and call it every time variable1 is changed. variable1 = 1; update_vars It's the best way I can think of. It's easy to write, and easy to read.

Categories : Matlab

MATLAB C/C++ API - Update big variable
You can only add new data to a file at the end of it, there is no way you can "insert data in the middle of a file" (or the beginning). You need to read the file, and write the new data. If the old data is smaller than the new data, there is no way this can be done "in situ", since the new data will overwrite some of the old data. Assuming you don't necessarily need to write it back to the original file, you could load a portion of the file at a time, and, at the beginning of processing, create a new file that you write the extended data into. Once you have written all the data, you can rename the new file to the original name of the input file, should you wish to.

Categories : C++

Determine provided values and copied values in SQL Server instead of update trigger
In the trigger, you can add a WHERE clause to compare old and new values and ignore non-changing rows. There is the function UPDATE() you can use but it can still gives true if the old and new values are the same. It isn't very reliable. However, there is no way to determine the actual columns in the SET clause of the triggering UPDATE call. That is, these look exactly the same to the trigger UPDATE [A] SET [X] = 2, [Y] = 1, [Z] = 1 WHERE [X] = 1 UPDATE [A] SET [X] = 2 WHERE [X] = 1

Categories : Sql Server

insert values in 3 table if the values do not exist or update it if ixist
As far as your error message concerned '...even if the values are inserted the system display the error msg: you must fill one of these fields befor you submit!!...' Your conditional is wrong. Change if(isset($_POST['city']) || isset( $_POST['lat']) || isset($_POST['long']) == "" ) to if ((!isset($_POST['city']) || $_POST['city'] == "") && (!isset($_POST['lat']) || $_POST['lat'] == "" ) && (!isset($_POST['long']) || $_POST['long'] == "")) { On a side note: your code is vulnerable to sql-injections. Switch to mysqli or PDO and learn prepared statements.

Categories : PHP

cannot update class definition in Matlab
You have an intermediate instance myClass.father that is not being destroyed by MATLAB. You have to deleteit yourself >> clear grandpa >> delete(son.precursors{1}) >> clear son >> clear classes >> son = myClass.son son = son >> sumVal(son) ans = 6 Edit: Alternatively, you can add a destructor to your class function delete(obj) if isa(obj.precursors{1}, 'myClass') delete(obj.precursors{1}); end end and use delete(son) instead of leaving it to clear function to destroy. You can extend this to your case and recursively delete all instances in your tree.

Categories : Matlab

How to insert or update all values in FIND_IN_SET and update the NOT FIND_IN_SET On Duplicate Key update
This procedure is not pretty, but its the best I can come up with given the concatenated IDs. It should also work faster than the FIND_IN_SET solution, because it can use the index on EMPLOYEE_ID. CREATE PROCEDURE `test`(IN `dep_id` INT, IN `emp_ids` TEXT) LANGUAGE SQL NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER COMMENT '' BEGIN START TRANSACTION; IF(emp_ids REGEXP '^[0-9,]+$') THEN #this will NOT guarantee a valid query but will prevent injections UPDATE TBL_DEPARTMENT_EMPLOYEES SET IS_ACTIVE=0 WHERE DEPARTMENT_ID=dep_id; SET @q = CONCAT(' INSERT INTO TBL_DEPARTMENT_EMPLOYEES (DEPARTMENT_ID, EMPLOYEE_ID, IS_ACTIVE) SELECT ?, EMPLOYEE_ID, 1 FROM TBL_EMPLOYEES WHERE EMPLOYEE_ID IN (',emp_ids,') ON DUPLICATE

Categories : Mysql

Update figure while waiting for event in Matlab?
You can use 'ButtonDownFcn' property (of the figure or axes) as mentioned by grantnz. ginput is more handy when there is a non real-time task. First of all, note that high level functions such as plot, imshow, image etc, will reset most of the axes properties such as 'HitTest' and 'ButtonDownFcn'. Thus after each time you use such functions you should update the required axes handle properties. In general you should avoid using such high level functions in a high frequency loop for better performance. In addition to setting 'ButtonDownFcn' of the axes implied by grantnz you can use the 'ButtonDownFcn' of the figure. Note that in second case you should turn off the selectability of the axes (set 'HitTest' of axes to Off). Here is a dummy animation, in which you can click on the animated

Categories : Matlab

How to update multiple graphs from one plot in one statement in Matlab?
Try redrawing the plot: xcoor = cellfun(@horzcat, get(p, 'XData'), {2; 3}, 'UniformOutput', false); ycoor = cellfun(@horzcat, get(p, 'YData'), {2; 3}, 'UniformOutput', false); c = [xcoor; ycoor]; plot(c{:})

Categories : Matlab

How can I count the count-values of Sequel::Dataset#group_and_count
I found a solution: sel = DB[:test].select(:count_value, Sequel::SQL::Function.new(:count, Sequel::Dataset::WILDCARD).as(:count)).group_by(:count_value) .from( DB[:test].select(Sequel::SQL::Function.new(:count, Sequel::Dataset::WILDCARD).as(:count_value) ).group_by(:key) ) puts sel.sql.downcase puts Sequel::PrettyTable.string(sel) This results in (SQL-command is 'pretty-printed by me): select `count_value`, count(*) as 'count' from ( select count(*) as 'count_value' from `test` group by `key`) as 't1' group by `count_value` +-----+-----------+ |count|count_value| +-----+-----------+ | 1| 19| | 1| 20| | 1| 21| | 1| 22| | 1| 23| | 1| 24| +-----+-----------+ Based on this solution I defined a new meth

Categories : Ruby

Reading values during entity values update?
How a consumer gets the data depends on what locking mechanism they use to access the database. They can choose the default which will wait for all of the objects to be updated, or they can choose to get something in a read-only fashion. Deciding on whether to update all at once or bit by bit depends on the tradeoff between how long you hold your locks and how much time you want to waste starting new connections. My guess would be that 22 seconds of DB write time is too much, so you may want to split up that workload. However on the other hand 22 seconds for 100 objects sounds like an long time, so you may have some performance problems slowing that down.

Categories : C#

Matlab erasing my values
You should listen to Mlint: You are using the class as if it were a reference, but it does not inherit from handle. Quick fix: classdef NaiveClass < handle And then read this: http://www.mathworks.de/de/help/matlab/matlab_oop/comparing-handle-and-value-classes.html

Categories : Matlab

How to map ranges of values in MATLAB
you can use linspace, for example linspace(0,1.15,101) will get you 101 points spread uniformly between the limits 0 and 1.15.

Categories : Matlab

find all indices of max values matlab
First you find the max value, then you find all the elements equal to that: m = max(myArray); maxIndex = find(myArray == m); Or using your variable names: maxChaqueCell = [4 5 5 4]; maximum = max(maxChaqueCell) indicesDesMax = find( maxChaqueCell == maximum ); This is how you find all of them, not just the first one.

Categories : Matlab



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