Adding rows to matlab table - matlab

I have a table named patients in matlab that I created from reading an excel file using the readtable command. Now I would like to add a new row to this table programmatically. I have attempted the following:
patients.LastName{end+1} = 'Stewart';
While this does add a value at the correct spot in the table, it gives a generic name to my row. My RowNames property in this instance is important.
How do I add a new row to my table in Matlab and give it a name, then populate it's contents?

This is because all other entries except Last Name are empty. But no worries. In order to assign specific Rownames, please use the following statement. Lets suppose you want to assign last names as row names of the table.
patients.Properties.RowNames = patients.LastName;

Related

Filemaker: Copy Global Variable from a Related Table?

I have a parent table that contains a global variable named gStartDate.
In a child table I have placed a global variable with the identical name. It has a calculated value:
ParentTable::gStartDate
However, it appears that it never copies the date from ParentTable::gStartDate. How can I correct this?
Thanks in advance to all for any info.
Its sounds like you set the calculated field in the child table to use "global" storage. That isn't going to update unless you update the schema or create a new record in the child table.
What you want is to set the calculated field to in the child table to be "un-stored". That will update when it is needed. And when it does it will pull the correct result from the parent table.
See the image.

Parsing fix xml and mapping fields to column names

I have some FIX reference data and I want to map fields to column names.
For example,
8=FIX.4.29=46535=d34=249=CX52=20131209-11:54:48.79556=ICAP67=182=900320=91322=77c945fd-f4b2-4c64-80db 912b6f7af287323=4393=900146=1311=515243309=TE0101S14E0060XXB305=H9801=I9802=EUI9803=S1 SUB 10Y9804=EUR9805=Y9806=Y9889=N9887=09807=259878=259879=3509906=259880=259881=3509907=259810=Y9811=0.259910=-19812=BPS9813=N9814=2I667EAA09815=201409209816=109851=609852=ITRX9853=N9883=IDB9884=A9896=Y9899=N9903=N9914=N9876=N9905=N10=140
If I were to paste this data into the parser I want to be able to insert the value for say tag 9802 to a row within a specific column.
Is there an easy way to do this?

SSRS Multiple Dataset Errors

I have a simple SSRS report that displays data from one table. What I want to do is have a distinct list from that table displayed in a drop down list for the user to select. If I only use one dataset I can get it to display, but it displays values from the column multiple times.
Example
Bob
Bob
Bob
Cathy
Cathy
If I create a second dataset that will list distinct values I get the following error message:
An Error occurred during local report processing. The definition of the report is invalid. The Variable expression for the report 'body' refers directly to the field without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
I"m trying to follow the example I found here:
http://msdn.microsoft.com/en-us/library/aa337400.aspx
The second dataset is only for the parameter list. I don't understand why it's causing problems with the actual report.
It's impossible to tell exactly where without the report definition, but there is an item on the report that is referencing a field or Dataset, and was implicitly using the only Dataset present in the report, but now doesn't know which Dataset to use once more than one is added to the report.
For example, when you create a table you can set a Dataset associated with it. If this is not set and there is only one Dataset, it doesn't matter as it will take the only one available. Once you add a new Dataset, the table doesn't know which one to use and you'll get the error you're seeing.
Another way to get the error is specifying a field in an expression, e.g. in a TextBox in the report somewhere without specifying the scope; just set the scope to a particular Dataset e.g. if you have:
=Count(Fields!name.Value)
change this to:
=Count(Fields!name.Value, "DatasetToUse")
If you've only got one Dataset the first expression will run fine by using the only one available, but once you add another it won't know which to use and it will error.
in the query (SQL) you should add DISTINCT clause at the beginning, that way, you will get only one record per value. Check out http://www.w3schools.com/sql/sql_distinct.asp
Double click the Dataset which contains that field.
Go to fields on the left and delete that field.
Add new field by clicking Add -> Query Field.
Just type in the name of the new field under field name and field source.
It happens when you have added a field by selecting "Calculated Field" instead of "Query Field" from Dataset Fields list tab.
Cheers,
Ahmed Latif

I want to Dynamically access SQLite result set?

I want to dynamically access SQLite result set. Since webworks/javascript doesnt support "PRAGMA table_info(table_name); I am saving all newly created tables information in a single two column table called schema. schema has two columns, table_name and column_name.
So I created a function to access table data dynamically. I use the item=results.rows.item(i) and than access row data with item.column.
column is a variable that is assigned the value from schema, representing the column_name. When I alert(column) I get the correct column_name, but when I used item.column my results are "undefined".
any advice on how to resolve this matter.
If I understand you correctly, column is a variable that holds the value of a column name, and you want to access that column from the results item. If that's the case, then this might help:
//Assuming "var column" has already been defined,
//and given the value of the column name to be accessed in the results item.//
var item = results.rows.item(i);
var columnValue = item[column];
I struggled with this too, and this is what I found/use. You put in brackets the variable containing the column name, and that's how you access it.
EDIT: This is obviously Javascript stuff, and what I used for accessing SQLite in PhoneGap. Hopefully it helps.

Can I add the same DataRow to a DataTable multiple times?

If I have a DataTable and want to create a new row I first call DataTable.NewRow() which returns a DataRow. This row then has the schema of the Table, and I can set the value of each field in the row. At this point does the Table "know" about the Row, or does that only happen after I call DataTable.Rows.Add(DataRow row)?
If I call DataTable.Rows.Add() more then once are duplicate rows created in the data table with duplicate values?
The reason I ask is I'm trying to write a recursive function that will iterate down a tree structure and populate a DataTable with values. So I have situations where rows being created for each child will have columns that have all the same values because they come from the parent.
So my idea was to pass a DataRow with the parent's information to each child. The child would add its information and then add the row to the table. But I'm trying to figure out if I need to call DataTable.NewRow() for each child, or if new rows will be created automatically if I add the same row multiple times.
No, but it's easy to copy a row so you can get what you want (assumes the existing row is in a variable called existingRow):
var newRow = dataTable.NewRow();
newRow.ItemArray = existingRow.ItemArray;
dataTable.Rows.Add(newRow);
Yes, old question. But Michael's answer does work. I needed to add multiple duplicate rows to a DataTable for a scheduling app. With dt.Rows.Add(_Users) I got the error:
This row already belongs to this table
But using this, I could loop through and hold as many positions open for a job as needed Where "Length" is the number of positions to hold open for a job:
int Length = int.Parse(TextBox6.Text.Trim());
for (int i = 0; i < Length; i++)
{
Users.Rows.Add("9999", "Open");
}
Searching Google for this sucks, because most people want to remove duplicate rows in a DataTable, and not add duplicate rows in a DataTable.
No, it will generate an exception of type System.ArgumentException.
i recommend that you put the data in a array and then add the data to data table
e.g.
yourDataTable.Rows.Add(data[0]........);
newdatarow will generate exception error