Change the file-name in tblwrite when created table - matlab

I want to create 15 txt tables with different names by using tblwrite in matlab. my attempt was in this code
for j=1:15
rownames=char(rownames1(:,j));
T(:,1)=[1:length(K_minus_t)];
table=char(T(j,1));
colnames{j}={'lambda_L';'C_L';'lambda_N';'tau_N';'lambda_c';'tau_c';};
values{j}=[coef_line lam_tau_curve lam_tau_cap];
tblwrite(values{j},colnames{j},rownames,'table.txt');
end
unfortunately, it was failed. Any help would be greatly appreciated. I will be grateful to you.

Related

Why is Access Dlookup Formula Giving Compile Error

so here's my problem. The below works:
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","WorkOrder=331091")
Unfortunately I need 331091 to be Combo4. Once I change the formula to:
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","WorkOrder"= [Combo4]") or
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","WorkOrder"= Combo4) or
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","[WorkOrder]"= [Combo4])
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","[WorkOrder]= [Combo4]")
I've been testing all the variations in Immediate Window and all result in Compile error: Expected: expression. Getting the same error in my other database which is why I created this one. One table, one record along with one unbound form. Table has WorkOrder and CylindersCompleted which are both Number and the form has one Combo and one textbox which are both Number. I'm putting the Dlookup formula in the Control Source of the textbox. I'm hoping someone can help me solve this issue so I can apply it to my other database which is much more complicated. Thanks in advance.
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","WorkOrder"= [Combo4]")
Should be:
=DLookUp("[CylindersCompleted]","WO_User_Input_Save","WorkOrder=" & [Combo4])

How can I make a for loop to read multiple txt files?

First of all, thank you so much. So, the problem is:
I have a function that Matlab has created by using the Import Data Tool. The function is called 'importkeff'. The problem is that I have a lot of txt files with the same structure and I havenĀ“t been able to create a for loop to execute the function and save the values in different vectors.
I have tried this but I know is wrong.
The txt files are named like this: 0000.V5W19.T17, 0001.V5W19.T17, 0002... and so until 0069.
for i=01:69
00ikeff19 = importkeff('00i.V5W19.T17')
end
Any ideas on how can I create a for loop to do it?
Thanks
keff = cell(69, 1);
for i=1:69
keff{i} = importkeff(sprintf("%04d", i) + ".V5W19.T17");
end

How to find highly similar observations in another dataset using Spark

I have two csv files. File 1:
D,FNAME,MNAME,LNAME,GENDER,DOB,snapshot
2,66M,J,Rock,F,1995,201211.0
3,David,HM,Lee,M,,201211.0
6,66M,,Rock,F,,201211.0
0,David,H M,Lee,,1990,201211.0
3,Marc,H,Robert,M,2000,201211.0
6,Marc,M,Robert,M,,201211.0
6,Marc,MS,Robert,M,2000,201211.0
3,David,M,Lee,,1990,201211.0
5,Paul,ABC,Row,F,2008,201211.0
3,Paul,ACB,Row,,,201211.0
4,David,,Lee,,1990,201211.0
4,66,J,Rock,,1995,201211.0
File 2:
PID,FNAME,MNAME,LNAME,GENDER,DOB,FNAMELNAMEMNAMEGENDERDOB
S2,66M,J,Rock,F,1995,66MRockJF1995
S3,David,HM,Lee,M,1990,DavidLeeHMM1990
S0,Marc,HM,Robert,M,2000,MarcRobertHMM2000
S1,Marc,MS,Robert,M,2000,MarcRobertMSM2000
S6,Paul,Row,M,2008,PaulRowM2008
S7,Sam,O,Baby,F,2018,SamBabyOF2018
For example, I want to extract those highly similar observations in File 2 with MarcHRobertM2000 in File 1.
My expected output will be:
S0,Marc,HM,Robert,M,2000,MarcRobertHMM2000
S1,Marc,MS,Robert,M,2000,MarcRobertMSM2000
I used the following code:
sqlContext.registerDataFrameAsTable(df2,'table')
query=""" SELECT PID, FNAMELNAMEMNAMEGENDERDOB, similarity(lower(FNAMELNAMEMNAMEGENDERDOB), 'MarcHRobertM2000') as sim
FROM table
WHERE sim>0.7 """
df=sqlContext.sql(query)
It looks like the similarity in SQL does not work in sqlcontext. I have no idea how to fix it. In addition, File 2 is big, around 5 GB so I did not use the fuzzywuzzy in python. And soundex is not satisfying. Could you help me? Thank you.
you can use Levenshtein distance function to check the similarity.
Please refer to the below code
query=""" SELECT PID, FNAMELNAMEMNAMEGENDERDOB, levenshtein(FNAMELNAMEMNAMEGENDERDOB, 'MarcHRobertM2000') as sim
FROM table
WHERE sim < 4 """
Also please check https://medium.com/#mrpowers/fuzzy-matching-in-spark-with-soundex-and-levenshtein-distance-6749f5af8f28 for good read.

How to turn a listbox.selecteditems into a variable with additional text

I am building a vocabulary trainer with a GUI and am stuck with a Listbox.
The Listbox has several topics to choose from and it works as requested.
Now I am struggling, to combine/merge the listbox.selecteditems, to add some text to it and put it into a variable
I tried to merge it by using the following code:
$TopicAnswer = '$listBox.SelectedItems_Answer'
[void] $ListBox.Items.Add('Weekdays')
[void] $ListBox.Items.Add('Months')
[void] $ListBox.Items.Add('Numbers 1-10')
[void] $ListBox.Items.Add('Numbers 10-20')
So the idea is, that when I for example choose 'Weekdays', I would like to have a variable that will become 'Weekdays_Answer'
I have tried several ways but usually end up with the content:
$listBox.SelectedItems_Answer
instead of
Weekdays_Answer
The idea behind it is, that I have pairs of arrays, where I have a topic name together with the topic name answer. So as soon as I have chosen a topic, I want a new variable that has this specific name and ads the underscore Answer to it, so I have the pairing arrays together for my vocabulary training.
What am I doing wrong?
Thank you for your help and support,
Mike
Thanx to you, I was able to figure it out.
$TopicAnswer = $listbox.text+'_Answer'
It works on this way. Thank you very much for your hint. You might did a typo but it helped to solve the issue.
Thanx,
Mike

KDB:Trying to read multiple csv files at a location

I am trying to run below code to read all csv files available at location C:/q/BitCoin/Input.Getting an error and dont know what the solution is?csv files are standard ones with three fields.
raze{[x]
inputdir:`:C:/q/BitCoin/Input;
filelist1:key inputdir;
filelist2:` sv' inputdir,'filelist1;
filelist3:string filelist2;
r:flip`Time`Qty`Price!("ZFF";",")0:x;
select from r
} each `$filelist3
Hard coding the file names and running below code works but I don't want to hard code
raze {[x]
r:flip`Time`Qty`Price!("ZFF";",")0:x;
select from r
} each (`$"C:/q/BitCoin/Input/bitbayPLN.csv";`$"C:/q/BitCoin/Input/anxhkAUD.csv")
Getting below error
An error occurred during execution of the query.
The server sent the response:
filelist3
Can someone help with issue?
The reason that you are receiving the error 'filelist3 is because filelist3 is defined in the lambda and outside of the lambda it is not recognised or defined. There are various ways to overcome this as outlined below.
Firstly you can essentially take all of the defined work done on the inside of the lambda and put it on the right side of the each.
raze{[x] r:flip`Time`Qty`Price!("ZFF";",")0:x; select from r
} each `$(string (` sv' `:C:/q/BitCoin/Input,'(key `:C:/q/BitCoin/Input)))
Or if you wanted to you could create a function which will generate filelist3 for you and use that on the right hand side of the each also.
f:{[inputdir] filelist1:key inputdir; filelist2:` sv' inputdir,'filelist1; filelist3:string filelist2; filelist3}
raze{[x] r:flip`Time`Qty`Price!("ZFF";",")0:x; select from r
} each `$f[`:C:/q/BitCoin/Input]
I hope this helps.
Many thanks,
Joel