5.608 total contributions since 2014

Suspensa Vix Via Fit

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...

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...

etwa 12 Stunden 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...

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...

etwa 18 Stunden 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...

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...

ein Tag ago | 0

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

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

ein Tag ago | 0

| 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 ...

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 ...

ein Tag ago | 1

| 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 ...

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 ...

ein Tag ago | 1

| accepted

Answered

How to find line of code that prints ans

Method one The MATLAB editor already identifies (most of) these lines for you! This is one of the many helpful features that t...

How to find line of code that prints ans

Method one The MATLAB editor already identifies (most of) these lines for you! This is one of the many helpful features that t...

ein Tag ago | 1

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 = ...

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 = ...

ein Tag ago | 0

| 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...

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...

ein Tag ago | 2

| 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...

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...

3 Tage 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 ...

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 ...

3 Tage 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...

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...

3 Tage 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; >...

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; >...

3 Tage ago | 1

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...

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...

3 Tage ago | 0

| accepted

Answered

Calling a function in MATLAB

To call a function or a script, just write its name with the necessary inputs: my_function(...) Or my_script This works in t...

Calling a function in MATLAB

To call a function or a script, just write its name with the necessary inputs: my_function(...) Or my_script This works in t...

3 Tage 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...

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...

3 Tage 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...

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...

4 Tage 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...

to print following pattern

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

4 Tage ago | 3

Answered

automatically filling a matrix

Just use blkdiag and a comma separated list: >> n = 5; >> j = 6; >> C = {-ones(n,1)}; >> M = blkdiag(C{ones(1,j)}) M = -...

automatically filling a matrix

Just use blkdiag and a comma separated list: >> n = 5; >> j = 6; >> C = {-ones(n,1)}; >> M = blkdiag(C{ones(1,j)}) M = -...

4 Tage ago | 0

| accepted

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 ...

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 ...

4 Tage 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...

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...

4 Tage ago | 0

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...

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...

4 Tage 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...

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...

4 Tage 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(:)),...

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(:)),...

5 Tage ago | 0

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...

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...

5 Tage 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

subtracting a number from string

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

5 Tage 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...

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...

5 Tage ago | 1

| 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...

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...

5 Tage 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))

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))

5 Tage 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: ...

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: ...

8 Tage ago | 0