I need help concerning libraries Alglib namely FFT. As I understand it, the input is a string, and the output is the same.
complex_1d_array z = "[1i,1i,1i,1i]"; - input
Can I make the input as an array? Thanks in advance.
Related
I need a formula that can multiply or divide all the numbers in a string without changing the text attached to the numbers.
I need the numbers in the next column to automatically change according to the given mathematical operation, but the text from the original line must remain unchanged.
I've tried using a combination of REGEXMATCH and REGEXEXTRACT and by doing this I just get the result of multiplying/dividing all the numbers in the string (no text whatsoever).
I also had no success using REGEXREPLACE. I'm not even sure we can actually use it in this case, and maybe I need a different formula instead. Maybe you first need to extract the numbers, multiply them and use something like TEXTJOIN or CONCATENATE to put them together in a string with the values already changed, and is this even possible in this specific example? It's totally fine to perform the operation in several steps if needed (for example, adding SPLIT function or something like that), but the format of the raw data we need to enter and recalculate, unfortunately, cannot be modified.
A sample table for better visualisation can be seen below. Any help would be greatly appreciated!
Raw data
Operation
Desired outcome
25STR/40DEX/70FRES
*0.25
6.25STR/10DEX/17.5FRES
80VIT/30INT/50CRES
*0.75
60STR/22.5INT/37.5CRES
60VIT/20STR/45LRES
*1.25
75VIT/25STR/56.25LRES
You may try:
=byrow(index(bycol(split(A2:A,"/"),lambda(z,ifna(ifs(left(B2:B,1)="*",regexextract(z,"\d+")*mid(B2:B,2,99),left(B2:B,1)="/",round(regexextract(z,"\d+")/mid(B2:B,2,99),2))®exextract(z,"\d+(.*)"))))),lambda(y,if(y="",,join("/",y))))
Okay, so I am writing a program that reads a file and prints all the lines in it. I don't want it to print lines that start with # and + and print all the other lines.
The code that I have written looks like this Code
The output looks like the following Output. So I want the output to print only those lines without starting with + and #.
I have stuck with this problem for a while and will really appreciate it if anyone can provide any hints as to what to do?
Thanks in Advance
Sorry I couldn't format the right coding style on stack overflow because I'm new but if you need help in understanding it don't hesitate to ask me
Regards,
Abdul Hadi
I have tried to solve this problem by reading old questions and by googles help.
I writing a short script in matlab where the user types in a equation and then plot the data by using eval.
But I want to check if the equation is right and uses the right variables and so...
I have three variables, X,Y,Z with upper case, so for example 'X+Y-Z-7.5' is a solid equation, but 'XB-Z' isn't. Just 'X' is also a solid "equation"...
How can I write the expression? Here is what I have...
regexp(test,'(X|Y|Z)$|(X|Y|Z|\d)&&(+|-|*|/|)')
My next plan is to do like,
if regexp(test,'(X|Y|Z)$|(X|Y|Z|\d)&&(+|-|*|/|)') == 1
disp ('Correct')
end
So I want the regexp return if the string matches the whole expression, not just startindex. I have problem to fix that too.
Please, I'm stuck.
One potential solution (if you have the Symbolic Math Toolbox) is to simply rely on that to determine whether the equations are valid.
You can use symvar to extract all symbols used in the equation and compare these to the variables you allow.
allowed = {'X', 'Y', 'Z'};
vars = symvar(userinput);
tf = ismember(vars, allowed);
if ~all(tf)
disp('Invalid Variables Used');
end
This is likely going to be much more robust than attempting to create regular expressions as it relies on MATLAB's internal parser.
I have a file of tweets that I have read into MATLAB using dataread and they're stored in a cell. I wanted to find the average number of characters in the tweets. How would I go about doing that? Here is the code I have so far:
fid=fopen('tweets.txt');
lines = dataread('file', 'tweets.txt', '%s', 'delimiter', '\n');
I was thinking I could use something along the lines of cellfun but I'm unsure how to format it. Any help would be greatly appreciated.
Try cellfun(#numel,lines), it returns the length of each line.
btw: fid=fopen('tweets.txt'); is unnecessary if you use dataread this way. Simply delete the line.
Are there any open-source word correction for c++? I would like to integrate with my c++ program to fix when OCR read some characters wrongly at some positions of the whole word. For example if the OCR output is "Recoqnitl0n" the program will correct it and convert to "Recognition".
Thank you
Yes, there are some open source spell checkers. Try:
hunspell
or
aspell