1

Statement of Matlab regex si

 2 years ago
source link: https://www.codesd.com/item/statement-of-matlab-regex-si.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Statement of Matlab regex si

advertisements

I want to have matlab take user input but accept both cases of a letter. For example I have:

function nothing = checkGC(gcfile)
if exist(gcfile)
    reply = input('file exists, would you like to overwrite? [Y/N]: ', 's');
    if (reply == [Yy])
        display('You have chosen to overwrite!')
    else
        $ Do nothing
    end
end

The if statement obviously doesn't work, but basically I want to accept a lowercase or uppcase Y. Whats the best way to do this?


Use the functions lower or upper. E.g.:

if (lower(reply) == 'y')

Alternatively, strcmpi will compare strings case-insensitively. E.g.:

if (strcmpi(reply, 'y'))

Related Articles

Using the switch statement to evaluate regex to javascript

I'm trying to manage my if statements into a switch statement to evaluate regex, but I don't know how I can go about it. I tried many possibilities but cannot do it. See code below, is it right?: var username = $('input.username'), phone = $('input.p

How to compare the array to a number for the if statement in matlab

H0 is an array [1:10] H is a single number [5] how to compare every element in H0 with the single number H so if H0>H do something, else do another thing, end Matlab always do the other thing.if requires the following statement to evaluate to a scala

Replace the vector elements using the / if state in Matlab

This question already has an answer here: Change elements of matrix based on condition 1 answer I would like to replace the elements of an vector using a condition or if function. a = [10 20 60]; if a < 30 = 4 else a = 5 the result needs to look like

Statement by Matlab while

I am using Matlab to develop my optimization project now. And I need use while loop to iterative . But I am not know what wrong with my statement in while loop. It works find with another similar problem last time. My code like this : while(norm(g_k)

if-elseif-else statement for MATLAB

I'm new to MATLAB (but not new to programming) and in my engineering class they are simply teaching the basics of if/elseif/else and loops. Well we have a homework assignment and I feel ashamed that I cannot figure it out. I must be missing the simpl

How to use the 'if' statement in matlab?

I have a cell array of size 5x5 as below B= 00 10 11 10 11 01 01 01 01 11 10 00 01 00 01 10 10 01 01 11 10 10 10 00 10 And two column vectors S1= 21 23 28 25 43 S2= 96 85 78 65 76 I want to create a new cell array of the same size as B say 5x5 such t

Delimiter options with dlmwrite statements in matlab

I have created 800 Poisson distributed random numbers. then write those numbers in a .txt file. I want to write my each data value in new line like, 1 2 3 but it is coming like 1 2 3.. I used dlmwrite as, dlmwrite('rts2_data.txt',rts2, '\t'); Which d

Matlab regex: How to enter a folder name in path

I need to get the folder name as follows: etc/my/folder/john/is/good I want "john". folder and is are always static (same). Just that "john" can be "jack" or other names, in this example. ThanksOne option, using positive look

Conditional statement about various regex and length of a python list

I have following list : ['E12.2', 'E16.1', 'E15.1'] ['E10.1', 'I11.2', 'I10.1_27353757'] ['E16.1', 'E18.1', 'E17.3'] ['E1.8', 'I12.1_111682336', 'I12.1_111682195'] ['E55.1', 'E57.1', 'E56.1','E88.1'] ['U22.3', 'U22.6_13735517', 'U23.1'] and I want to

How to imitate negative statements on Qt regex?

I am writing a program using Qt 4.6 and I need to capture all occurences of non-range literals from expressions like "SUM(A1:A3)+B1-B3+SUM(D1:D3)/COUNT(D1:D3)", i.e. B1, B3, but not A1, A3, D1, D3. I have tried to use QRegExp, but it doesn't sup

How to extract the drbd state using grep / regex / cut / awk / sed etc.

From my output from /proc/drbd I am trying to extract 'UpToDate/UpToDate' section of this output per device (0 and 1). I tried: cat /proc/drbd | grep ' 0:' | grep -Eo 'ds:(.*)' But that gives me: ds:UpToDate/UpToDate C r----- That is not what I'm loo

Matlab: Regex to remove consecutive white space and punctuation

I have a string array that I need to clean up. For example I have: textfile = I would like to play in the woods on a shine bright day which comes soon enough. I would like to play in the woods on a shine bright day which comes soon enough. There are

How do I compare numbers using if and / or statements in matlab?

I want to return true if the element of an array b=[1,2,3,4,5] equals 1 or 2 or 5. How do I do this?There are different ways to do that: Test an individual element against one number b(1) == 5 Test an individual element against several numbers, i.e.

MySQL: use REGEX to extract a string (select REGEX)

I would like to have a mysql query like this: select <second word in text> word, count(*) from table group by word; All the regex examples in mysql are used to query if the text matches the expression, but not to extract text out of an expression. I

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK