w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Use textscan in Matlab to output data
Try this: FID = fopen('datafile.dat'); data = textscan(FID,'%f %f %f %f', 'headerLines', 6); fclose(FID); data will be a 1x4 cell array. Each cell will contain a 3x1 array of double values, which are the values in each column of your data. You can access the 2nd and 4th columns of your data by executing data{2} and data{4}. With your original code, the main issue is that the data file has 6 header lines but you've specified that there are only 4. Additionally, though, you'll run into problems with the specification of the number of times to match the formatSpec. Take for instance the following code data = textscan(FID,'%f',4); which specifies that you will attempt to match a floating-point value 4 times. Keep in mind that after matching 4 values, textscan will stop. So for th

Categories : Matlab

Matlab: Textscan with blank spaces
You need to use the 'Delimiter' option for textscan (I also changed the %c on the spaces to %s to avoid reading the delimiter). str = '5,6, ,AUD,JUN11,ABCD4,APPM,CME,4PTS09,F,6A,11, , ,1,1.7,10,27,23,1,NCAP1,0'; Data = textscan(str, '%d%d%s%s%s%s%s%s%s%s%s%d%s%s%d%f%d%d%d%d%s%d', 'Delimiter', ',');

Categories : Matlab

textscan strange behaviour in matlab
This works: str = 'ahmed;mohamed'; C = textscan(str, '%s', 'Delimiter',';', 'CollectOutput',true); C = C{1}; with: >> C C = 'ahmed' 'mohamed'

Categories : Matlab

MATLAB: Using textscan and converting cell array in matrix
As you have an array containing both numeric and character data, what you want is impossible (and trust me, it would be impractical, too). Referencing individual numbers in a numeric array is different from referencing whole strings. There is simply no escaping that, nor should there be: you treat flowers differently from how you treat people (I sure hope so anyway). In MATLAB, a string is an ordinary array, with the difference that each entry of the array does not represent a number, but a character. Referencing individual characters goes the same as referencing numbers in arrays: >> a = 'my string' >> a(4) ans = s >> a+0 % cast to double to show the "true character" of strings ans = 109 121 32 115 116 114 105 110 103 However, textscan assu

Categories : Arrays

Error reading a fixed-width string with textscan in MATLAB
I suspect textscan first trims leading white space, and then parses the format string. I think this, because if you change yuor format string from '%9f%9f' to '%6f%9f' your one-liner suddenly works. Also, if you try '%9s%9s' you'll see that the first string has its leading whitespace removed (and therefore has 3 characters "too many"), but for some reason, the last string keeps its trailing whitespace. Obviously, this means you'd have to know exactly how many digits there are in both numbers. I'm guessing this is not desirable. A workaround could be something like the following: % Split string on the "dot" dat = textscan(<your data>,'%9s%9s',... 'Delimiter' , '.',... 'CollectOutput' , true,... 'ReturnOnError' , false); % Correct the strings; move the

Categories : String

Importing large textfile to matlab (including comments; textscan)
You can use segarray = textscan(fid, '%f %f %f %f %[^ ]'); to achieve what you want (so without any options to textscan()). The last format character means that textscan will match any trailing character(s) that are not newline. This results in: test.txt: 667.55535 -0.00 0.000 0.0158 667.5554 -0.01 -0.000 0.0158 667.55545 -0.01 4.037 10.0000 667.5555 -0.00 4.000 10.0000 #1 Trigger Camera 10 Hz #2 Trigger Camera 10 Hz 667.55555 -0.00 4.000 10.0000 667.5556 -0.01 4.000 10.0000 667.5555 -0.11 4.000 12.0000 #1 Trigger Camera 11 Hz #2 Trigger Camera 12 Hz 667.5557 -0.00 4.000 10.0000 667.556 -0.01 4.000 10.0000 667.55855 -0.00 4.000 10.0000 667.5596 -0.01 4.000 10.0000 667.55105 -0.00 4.000 10.0000 667.5511

Categories : Matlab

Reading fortran direct access data and writing formatted data - faster with python than with fortran?
Try using StreamIO see http://www.star.le.ac.uk/~cgp/streamIO.html That should allow random access without fixed record size and will probably result in using the same underlying O.S. system calls, thereby hopefully getting the same performance.

Categories : Python

sqlite3_open_v2("/data/data/com.food.find/databases/mydatabase", &handle, 2, NULL) failed in android?
This code is dreadful. I'd start by deleting the entire thing and beginning again. First, if you are going to package a database with your app, do not write your own code for that. There is an existing library, SQLiteAssetHelper, that is tested, debugged, and supported. More importantly, it is written by somebody (Jeff Gilfelt) with a lot of Android development experience. Second, if you are using a SQLiteOpenHelper (or a subclass like SQLiteAssetHelper), and you are also writing openDatabase() anywhere for that database, YOU ARE DOING IT WRONG. The complete and entire point behind SQLiteOpenHelper is to have it open the database for you, so it can create or upgrade that database if needed. Third, if you are using SQLiteOpenHelper (or a subclass like SQLiteAssetHelper), and you have emp

Categories : Android

Data is not properly stored to hsqldb when using pooled data source by dbcp
Your method of accessing the database from outside your application process is simply wrong. Only one java process is supposed to connect to the file: database. In order to achieve your aim, launch an HSQLDB server within your application, using exactly the same JDBC URL. Then connect to this server from the external client. See the Guide: http://www.hsqldb.org/doc/2.0/guide/listeners-chapt.html#lsc_app_start Update: The OP commented that the external client was used after the application had stopped. Because you have turned the log off with hsqldb.log_data=false, nothing is persisted permanently. You need to perform an explicit CHECKPOINT or SHUTDOWN when your application completes its work. You cannot rely on shutdown=true at all, even without connection pooling. See the Guide: h

Categories : Database

Ember: use controller data in route or how to fetch data properly
I have been struggling with this problem as well. In some of my apps, I've needed the URL to control the date range (e.g. a particular month). In these cases, I would created a MonthRoute and a MonthModel - think of it as a monthly report. The MonthModel has a hasMany property of the actual data I wanted to chart: App.Month = DS.Model.extend({ companies: DS.hasMany('App.Company') }); A datepicker would let the user enter a new route, which would fetch (say) the Jan-2013 month model { month: { id: 'Jan-2013', companies: [ {name: 'Acme, Inc', revenue: 10425, ...}, ... ] } } Then, I would set the embedded companies data on my CompaniesController in the setupController hook: App.MonthRoute = Ember.Route.extend({ setupController: function(controller, mode

Categories : Ember Js

The best way to read formatted data from NSString?
Try using NSString methods like this: NSArray *vals = [string componentsSeparatedByString:@" "]; float f1 = [vals[1] floatValue]; float f2 = [vals[2] floatValue]; float f3 = [vals[3] floatValue];

Categories : IOS

jqPlot and JSON formatted Data
The problem is your JSON structure: { "Admits": "35", "Discharges": "36" } You are providing a JSON object, but jqplot needs array instead: [ ["Admits", 35], ["Discharges", 36] ]

Categories : Json

Reading formatted data from file in C++
You can use cin.getline() which will read the remainder of the line. First read the digit, then use getline() to read everything remaining.

Categories : C++

display formatted data from database to richtextbox
Rich text seems to always starts with { tf (I may be wrong. But it seems like a fair assumption). So it you check for that, you'll be able to decide. Please see this link for a convenient extension method to do this. Code from msdn forum /// <summary> /// Returns the DataFormat string of the text. /// </summary> /// <param name="text">Text to check.</param> /// <returns>Value from the <see cref="DataFormats"/> enumeration.</returns> public static string GetDataFormat(this string text) { // First validate the text if (string.IsNullOrEmpty(text)) return System.Windows.DataFormats.Text; // Return right data if (text.StartsWith(@"{ tf")) return System.Windows.DataFormats.Rtf; // Return default return System.Windows.Data

Categories : C#

Mongodb is returning wierdly formatted data
No, that's supposed to be like that. MongoDB uses BSON, which extends JSON with some extra types, such as ObjectId. To represent those in JSON, you get the weird-looking $oid and friends. The backslashes are most likely added by some tool to allow for quotes inside of a String literal (which is enclosed by quotes). Unless you are somehow double-encoding things.

Categories : Python

Reading data from specially formatted text file
Something like this: import re with open('abc') as f: for line in f: if line.startswith('Key'): keys = re.search(r'Keys+(.*)',line).group(1).split(" ") elif line.startswith(('Word','Letter')): vals = re.search(r'(Word|Letter)s+(.*)',line).group(2).split(" ") print dict(zip(keys,vals)) abc: LineHere w x y z Key a 1 b 2 c 3 d 4 OrHere 00 01 10 11 Word as box cow dig output is : {'d 4': 'dig', 'b 2': 'box', 'a 1': 'as', 'c 3': 'cow'} abc: LineHere w x y z Key a 1 b 2 c 3 d 4 OrHere 00 01 10 11 Letter A B C D output is : {'d 4': 'D', 'b 2': 'B', 'a 1': 'A', 'c 3': 'C'}

Categories : Python

retrieve json formatted data using xmlhttp request
Without seeing exactly what your JSON looks like it is hard to know for sure. However since you are encoding an array, I suspect changing: a.items to a[0].items will do the trick... Edit I would do: document.getElementById('daily').innerHTML = JSON.stringify(a.items); That will convert your object into a string that can be assigned to the innerHTML of an element. I am not sure if this is exactly what you want to do, but when you find the element you want to display using that method should work. Edit 2 You could change your PHP to only output what you want. However, you could filter it in your JS as well: a.items[0].pic and a.items[0].article If those don't display as is you can use the stringify method, but you shouldn't need to since those items appear to be strings

Categories : PHP

Upsampling data in matlab gives a "drift" in the data
One common problem with working with MATLAB is that all vectors, matrices, etc use 1-based indexing, rather than the more natural 0-based indexing that is typically used in maths, engineering, DSP, etc. In your particular case the calculation for position needs to be changed from: position = round(time(i)*fs); to: position = 1 + round(time(i)*fs); to get the correct correspondence between time and (1-based) sample number.

Categories : Matlab

How to display formatted HTML data in kendo ui grid column
You should define a column template. Example: <script id="ob-template" type="text/x-kendo-template"> <div class="class1"> <div>This is <strong>bold </strong>text.</div> <div> </div> <div>This is <em>italics</em> text.</div> <div> </div> <div>This is a <a href="http://google.com/">hyperlink</a>.</div> <div> </div> <div>Bulleted list:</div> <ul> <li>Bullet #1</li> <li>Bullet #2</li> <li>Bullet #3</li> </ul> </div> </script> and then, when you define the columns use it: $("#grid").k

Categories : Kendo Ui

Plotting CSV with semi-colons and time formatted data with Gnuplot
First, apparently you can set the delimiter thus: set datafile separator ";" Then set the time format for your first file, and set x to be a time axis: set timefmt "%d.%m.%y - %H:%M:%S" set xdata time Plot the first file plot "data1.csv" using 1:2 The second file x values don't seem to have a date format, but instead perhaps seconds elapsed? For that, just do set datafile separator ";" plot "data2.csv" using 1:2 and don't set xdata time. Then you should have an x axis in seconds. If you need to plot both at the same time, it would be simplest to pre-process one to look like the other.

Categories : Csv

How can I handle different data types in an Entity-Attribute-Value design (e.g. single table with multiple columns or multiple tables per data type)?
This is a well known problem. The problem with the approach you mentioned is that you need to know the type of the attribute before you query for it. it's not the end of the world because you manage metadata but still... Two possiable solutions might be using a varchar2 datatype to represent all data types in a known format. Numbers and chars are no problem, date values can be written in a predefined manner (it's like implementing to_String() in any OO design). use the ANYDATA data type. i personally played around with it but decided not to use it.

Categories : Database

handle & in data during data binding
You can use filter for format it. <input placeholder='Name' type="text" ng-model="form.firstName | html" ng-required="true" /> Add this filter: angular.module("formatFilters", []).filter('html', function() { function(input) { return input.replace(/&amp;/g, "&"); }; }); At last,don't forget add this filter in to module. angular.module("app", ['formatFilters'])

Categories : Javascript

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 - Can I make my handle object behave like a graphics handle?
Example: MyObject.m classdef MyObject < handle properties x end methods function obj = MyObject(x) if nargin < 1, x = NaN; end obj.x = x; end end end MATLAB >> a = MyObject.empty(0,3) a = 0x3 MyObject array with properties: x >> a(3) = MyObject(10) a = 1x3 MyObject array with properties: x >> a(3) ans = MyObject with properties: x: 10 >> a(1) ans = MyObject with properties: x: NaN Note that the objects a(1:2) were constructed by calling the default constructor with no arguments. An alternative way: >> a = cell(1,3) a = [] [] [] >> a{3} = MyObject(10) a = [] [] [1x1 MyObject] Note: handle graphics (HG) are not implemen

Categories : Arrays

link URL is not properly formatted thrown in
Ok. So it does looks like Facebook is blocking links to localhost. What you'll want to do to circumvent this limitation is to create an entry in your hosts file with a dummy hostname pointing back to 127.0.0.1. Something like: fakelocalhost.com 127.0.0.1 Then just replace your URL with this fake hostname: 'link' => 'https://fakelocalhost.com/Sweepstack/publishedtab.php?ref=15'

Categories : PHP

My jQuery, AJAX call is getting a null response on a valid return of well-formatted JSON data from a PHP function
I would suggest opening up Developer Tools in Chrome (View > Developer > Developer Tools) and selecting the Network tab. When your AJAX post request is made, it should add an entry there (the "Path" column should be "index.php/controllerFile/get_standby" and the "Method" column should have "POST"). Click the row for the request and check the Response tab to make sure your JSON is there. If the response is empty, your problem is with your PHP code (you might not be printing the JSON returned from that function to the page). Otherwise, it would seemingly be a problem with your JavaScript.

Categories : PHP

How to parse a specifically formatted timestamp text into data that can be used for date/time arithmetic in Java code?
You can use the following syntax to parse the string into date object. Date d = new Date("Wednesday Aug 28, 2013, 02:44 AM GMT"); This will return the date object and by comparing it with current time you can get the posts made over last 24 hrs.

Categories : Java

How to handle TCP data?
You can use a Handler targeted to Looper.getMainLooper() to efficiently, repeatedly post data to the UI thread from a background thread. The Communicating with the UI Thread section of the Android Training pages explains how to use a Handler. I also wrote a blog post about Loopers a while ago that reveals a bit about how they work.

Categories : Android

How To Handle Incorrect CLLocation Data
Change if ([lastLocation horizontalAccuracy] < 20)... to if (([lastLocation horizontalAccuracy] > 0) && ([lastLocation horizontalAccuracy] < 20))... According to documentation A negative value indicates that the location’s latitude and longitude are invalid. A negative value of horizontalAccuracy that is. If you want to set the condition for processing data (seems like you do) you should rewrite the code to: if (([lastLocation horizontalAccuracy] > 0) && ([lastLocation horizontalAccuracy] < 20)) { didFindGPS = YES; //process the data here... since here the location fits your limitations //and you don't loose the first location (as in original code) } else { didFindGPS = NO; } Note that this code can give you some false al

Categories : IOS

Chrome App: Handle Sensitive data
Consider using the WebCrypto API to implement encryption of the token, then store the ciphertext in chrome.storage. You'll ask the user to supply a master password to encrypt and decrypt tokens. On each launch of the app you'll prompt the user for the master password, to avoid the need to store it anywhere. In all likelihood, you'll grow tired of entering the master password each time and will implement an option to store the password right next to the stuff it unlocks in chrome.storage, or you'll pick a password that's short and easy to type. In either case, the usability of the system will ensure that the password serves effectively no purpose, other than security theater.

Categories : Security

How to handle authentication data correctly through the whole app
I have a custom subclass of NSMutableURLRequest where I do all kinds of auth and other stuff specific to my server. I keep a couple of static NSStrings in that module. (It's even a little naughtier than a singleton, but take that singleton advice with a grain of salt...Singletons aren't satanic, they're just discouraged). Sometimes you really need to have just one of something.

Categories : Objective C

How to Handle JSON data in android
users is not a JSONArray but a JSONObject: Change jArray = json_data.getJSONArray("users"); with JSONObject jObj = json_data.getJSONObject("users");

Categories : Android

How to handle transactions with Spring Data JPA?
I am not clear for your question. What is the Domain Services doing? I knew Application Services and Domain Repositories very well. In spring , there are two layers service and data access layer. Service layer can used @Service (In your design it will be application Services) but not used @Transactional Tag. Data access layer used @Repository Tag and also @Transactional Tag, Because This layer is directly connected and make operation with the Database. So, I like to know what 's function of the Domain Service. I am not clear for that. Thanks buddy.

Categories : Spring

Summarized huge data, How to handle it with R?
You did not give a great reproducible example so this will be pseudo/untested code. Read the docs carefully and make adjustments as needed. I'd suggest you first filter and split your data into two data.frames: best.bid <- subset(data, side == 0 & distance == 1) best.ask <- subset(data, side == 1 & distance == 1) Then, for each of these two data.frames, use findInterval to compute the corresponding best ask or best bid: best.bid$ask <- best.ask$price[findInterval(best.bid$time, best.ask$time)] best.ask$bid <- best.bid$price[findInterval(best.ask$time, best.bid$time)] (for this to work you might have to transform date/time into a linear measure, e.g. time in seconds since market opening.) Then it should be easy: min.spread <- min(c(best.bid$ask - best.bid$pri

Categories : R

How to get/handle POST data in ASP.NET MVC 4 Razor?
You need to use the helper methods so that MVC knows how to bind the values and then in the controller you will be able to use the model (as the model binder will figure it out for you) e.g. @model Models.AuthForm @{ ViewBag.Title = "СЭЛФ"; } @section home { @using (Html.BeginForm("Auth", "Controller")) { <div class="control-group"> @Html.LabelFor(model => model.Login, new { @class = "control-label" }) <div class="controls"> @Html.TextBoxFor(model => model.Login, new { @class = "input-large", autocapitalize = "off" }) @Html.ValidationMessageFor(model => model.Login, "*", new { @class = "help-inline" }) </div> </div> <div class="control-group"> @Html.LabelFor(model => mo

Categories : C#

Optimized way to handle constant map data
If you want the sorted map then use Tree Map. If requirement is to iterate on the entries in the same order as they were put,consider LinkedHashMap Otherwise always prefer the HashMap if you dont care about any of the above criteria EnumMap is a specialized Map implementation for use with enum type Keys.see http://docs.oracle.com/javase/7/docs/api/java/util/EnumMap.html.So if your keys are of Enum types go for it.

Categories : Java

How to Handle Large Data in Java?
You can use an embedded database, you can find a comparison here: Java Embedded Databases Comparison. Or, depending on your use case you may even try to use Lucene which is a full text search engine.

Categories : Java

How handle data from sharedpreferences getStringSet?
Why not use String [Split?][1] String id = iterator.next(); id = id.substring(1, id.length()-1) String[] parts = id.split(","); String part1 = parts[0]; // Left Near fender String part2 = parts[1]; // false

Categories : Java

How to handle better data from HashMap in Java?
I can't see what is the name of your map... But assuming you have something like: Map<String, TabManager> map = new HashMap<>(); where the string is the name of your tab, is unique per tab, and that you can get that name with tab.getTabSelected(), then you can do: TabManager selectedTab = map.get(tab.getTabSelected()); to get the selected tab. About your second question: how to handle that big data... Since you don't want to read and copy in memory the entire file every time, you want: start and end file pointers to know which chunk of the file you are currently displaying cache for all tabs the page each of them displays open the file when the tab is selected and the cache is out-of-date or not covering the info you need, close it when the tab is not selected anymore

Categories : Java

How to handle Null value in Data Link Layer?
I think you're looking for SqlDataReader.IsDBNull Method Check whether the database field contains null value Handle it with String.Empty Here is an sample that I have used logSource = (!reader.IsDBNull(0)) ? reader.GetString(0).Trim() : ""; From your comments, ObjUnutilizedOwnershipEntities.Dt_VisaValidFrom = (!IsDBNull(osqlDataReader["Dt_VisaValidFrom"])) ? Convert.ToDatetime(osqlDataReader["Dt_VisaValidFrom"].ToString()) : "";

Categories : C#



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