Answered
String Search with Special Characters
You can use tokens to identify the specific substrings and get their locations: >> S = '>ABCD 2345678.123<'; >> [T,X] = regexp...

7 years ago | 1

Answered
How to find where are the location of the original values after the matrix was sorted
>> old = randi(9,6,4) % fake data old = 8 6 3 6 1 4 9 4 8 1 4 8 6 3 8 7 3 8 4 ...

7 years ago | 0

| accepted

Answered
If statement using vectors
You cannot use if like that to operate element-wise on arrays (read the if help to know what your code is actually doing). You c...

7 years ago | 0

| accepted

Answered
The variables which were stored in handles gets deleted once the program control gets out of the function loop despite using guidata()
You need to call guidata inside processe. In its current location, your first guidata does nothing. num=processe(hObject, handl...

7 years ago | 0

Answered
How can I extract a variable that is calculated inside an ode function and pass it as an input to the event function?
The simplest solution is to use nested functions: https://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html Basi...

7 years ago | 0

| accepted

Answered
How to create the array [1, 2,2 ,3, 3, 3, 4,4 4, 4]?
>> V = 1:10; >> floor(sqrt(2*V)+1/2) ans = 1 2 2 3 3 3 4 4 4 4

7 years ago | 0

| accepted

Answered
How to extract values from a string.
>> S = 'Delft_2_220_20_4344-5088.csv'; >> V = str2double(regexp(S,'\d+','match')) V = 2 220 20 ...

7 years ago | 1

| accepted

Answered
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
The actual problem starts on this line: f=@(t,z)[ ... because your code is missing the matching ] Using = was correct. Note ...

7 years ago | 1

| accepted

Answered
Problem with my if else command
An IF statement is not appropriate (without a loop). The simple MATLAB way is to use indexing: >> a = 1; >> b = 1; >> x_15 = ...

7 years ago | 1

| accepted

Answered
Not equal operator not working on matrix size
"Why does == work as expected, but ~= doesn't?" They both work exactly as expected. "Did I make a mistake?" The IF documentat...

7 years ago | 3

| accepted

Answered
Transform NaN into number
Your original description failed to mention several things, including the size of the numeric vector and also that the numeric v...

7 years ago | 1

Answered
creating a vector from a bin count
R2015a or later: >> M = [0 5; 1 2; 2 1]; >> repelem(M(:,1),M(:,2)).' ans = 0 0 0 0 0 1 1 2 ...

7 years ago | 1

| accepted

Answered
displaying matrix in .txt file (fprintf)
No loop required: mat = [1,1,1,1;0,-49+4i,-49-4i,-52;0,-2417,-2417,-2392;0,-117649-64i,-117649+64i,-117676]; fmt = ' |%.2f%+.2...

7 years ago | 0

Answered
How to create an empty struc with fields of a given struct?
The simplest and most efficient solution to the question posed is to just use indexing, e.g.: >> A(1).x = 1; >> A(1).y = 2; >...

7 years ago | 10

Answered
How do I get a bar chart in the newest version but with the colors from an older version?
"I have not been able to locate a definitive answer to what the default colors are for a bar chart." The bar documentation stat...

7 years ago | 0

| accepted

Answered
Undesired behaviour of bsxfun and colon-operator
A robust workaround using ndgrid and arrayfun and exactly the same function: >> [X,Y] = ndgrid(1:3,6:9); >> arrayfun(@(x,y)x+s...

7 years ago | 0

| accepted

Answered
How can I create all possible random combinations of word pairs without having the same values (for example, house - house)?
Pick random rows from X to get the random pairs: >> Tile = {'house', 'core', 'word', 'ask', 'question', 'horse', 'phone', 'eyes...

7 years ago | 0

| accepted

Answered
to print following pattern
Three lines, no loop, and only basic numeric operations used: >> X = 1:9; >> Y = floor((137174210/1111111111)*10.^X); >> fpri...

7 years ago | 3

Answered
combining different csv files from a folder into one matrix
"Is theremaybe a way to list the filenames in the same order, then add them afterwards as the top row to the table?" You could ...

7 years ago | 0

| accepted

Answered
Inserting more rows between already existing rows of a structure
"but I am not sure how to tansfere that onto a structure. " In exactly the same way. All MATLAB arrays use the same indexing co...

7 years ago | 0

| accepted

Answered
How to use eval and disable the edit box or drop down?
Do NOT use eval for trivial code like this! Much better is to read the documentation on dynamic fieldnames: https://www.mathwo...

7 years ago | 1

| accepted

Answered
How do I extract images from a docx (word) file?
All OpenOffice XML formats (e.g. .docx, .xlsx, etc.) constitute XML files and supporting files zipped together into one file. Yo...

7 years ago | 0

Answered
Generate combinations of Cells that contain text
Simple and efficient with ndgrid and strcat: >> [Cx,Bx,Ax] = ndgrid(1:numel(C),1:numel(B),1:numel(A)); >> D = strcat(A(Ax(:)),...

7 years ago | 2

Answered
Find Borders and their Indices
Simple and efficient using diff and find: >> D = diff([false,A==0,false]); >> B = find(D>0) % begin of run of zeros B = 1...

7 years ago | 1

| accepted

Answered
subtracting a number from string
The most efficient solution by far (and simple too!): >> str = 'subject1_EO'; >> val = sscanf(str,'subject%f') val = 1

7 years ago | 0

Answered
Convert cell to duration array
"Is there an elegant equivalent to "cell2mat" when cell content is "duration"?" Yes, this is really easy with a comma-separated...

7 years ago | 2

| accepted

Answered
i have a problem with use of natsortfiles function and divide my images
It is not clear what you expect this line structtt = cat(1,cellFileNames{:}); to do, but in actual fact it will vertically con...

7 years ago | 1

| accepted

Answered
how can i express the following question in matlab about save command?
Use uiputfile for a more professional user interface, e.g.: [F,P,X] = uiputfile({'*.jpg';'*.png'}); imwrite(A,fullfile(P,F))

7 years ago | 0

Answered
how to loop through subfolders and apply a particular function
A simple function which correctly handles special characters in the pattern and actually calls the nested function recursively: ...

7 years ago | 0

Answered
replacing uiget with pathname and filename
You use dir without any specific name+wildcards, so it will return all contents of that folder (i.e. files and folders). You the...

7 years ago | 1

| accepted

Load more