답변 있음

Interval where values are greater than treshold

>> B = find([true;diff(Logic(:))>0]); >> E = find([diff(Logic(:))<0;true]); >> M = [B,E] M = 1 3 7 8 10 ...

Interval where values are greater than treshold

>> B = find([true;diff(Logic(:))>0]); >> E = find([diff(Logic(:))<0;true]); >> M = [B,E] M = 1 3 7 8 10 ...

약 15시간 전 | 0

| 수락됨

답변 있음

count a sequence of 1 or 0

>> M = [0,0;0,1;1,1;1,0;1,1;1,0;0,1;1,1;0,1;0,1] M = 0 0 0 1 1 1 1 0 1 1 1 0 0 1 ...

count a sequence of 1 or 0

>> M = [0,0;0,1;1,1;1,0;1,1;1,0;0,1;1,1;0,1;0,1] M = 0 0 0 1 1 1 1 0 1 1 1 0 0 1 ...

약 16시간 전 | 1

| 수락됨

답변 있음

Elementwise Matrix multiplication with a Vector to get a higher dimension Matrix

"How can I make my Code more efficient?" A2 = bsxfun(@times,A1,reshape(V1,1,1,[])) % for versions >= R2007a A2 = A1 .* reshap...

Elementwise Matrix multiplication with a Vector to get a higher dimension Matrix

"How can I make my Code more efficient?" A2 = bsxfun(@times,A1,reshape(V1,1,1,[])) % for versions >= R2007a A2 = A1 .* reshap...

약 16시간 전 | 1

답변 있음

Why does my code think I want to use the Symbolic Math Toolbox when in reality I want to solve a system of ODEs numerically?

Take a look at these two lines: %% create function handle to euler, which contains ODEs fun=@euler; euler is in the symbolic ...

Why does my code think I want to use the Symbolic Math Toolbox when in reality I want to solve a system of ODEs numerically?

Take a look at these two lines: %% create function handle to euler, which contains ODEs fun=@euler; euler is in the symbolic ...

약 17시간 전 | 0

| 수락됨

답변 있음

How to get the mean of a cell array of matrices

>> out = permute(num2cell(mean(cell2mat(permute(test,[1,3,2])),1),2),[1,3,2]); Checking: >> size(out) ans = 1 1000 ...

How to get the mean of a cell array of matrices

>> out = permute(num2cell(mean(cell2mat(permute(test,[1,3,2])),1),2),[1,3,2]); Checking: >> size(out) ans = 1 1000 ...

약 20시간 전 | 0

| 수락됨

답변 있음

I need to convert a number into its column name equivalent

Unfortunately Andrei Bobrov's answer does not really take into account the missing zeros, which means that it leads to a kind of...

I need to convert a number into its column name equivalent

Unfortunately Andrei Bobrov's answer does not really take into account the missing zeros, which means that it leads to a kind of...

약 22시간 전 | 0

답변 있음

Plot by loading a vector, saved from a different workspace as .mat file(converting struct to vector)

Use a loop, e.g.: D = 'temp'; % path of the folder where the files are saved. N = [10,15,20]; C = 'rgb'; for k = 1:numel(N) ...

Plot by loading a vector, saved from a different workspace as .mat file(converting struct to vector)

Use a loop, e.g.: D = 'temp'; % path of the folder where the files are saved. N = [10,15,20]; C = 'rgb'; for k = 1:numel(N) ...

약 24시간 전 | 0

답변 있음

regexp help when comparing strings

"Strings which are compared are identical" In general regular expressions are NOT used to compare identical strings (although i...

regexp help when comparing strings

"Strings which are compared are identical" In general regular expressions are NOT used to compare identical strings (although i...

2일 전 | 1

| 수락됨

답변 있음

Generating vector with n elements from a to b with the same incrementation

linspace(a,b,n) https://www.mathworks.com/help/matlab/ref/linspace.html

Generating vector with n elements from a to b with the same incrementation

linspace(a,b,n) https://www.mathworks.com/help/matlab/ref/linspace.html

2일 전 | 0

답변 있음

a easier way to do vector

"Is there any easier or more efficient way to calculate SF when there is different k?" Do NOT use numbered variables, they are ...

a easier way to do vector

"Is there any easier or more efficient way to calculate SF when there is different k?" Do NOT use numbered variables, they are ...

3일 전 | 0

| 수락됨

답변 있음

Starting from the year 1697, store all leap years until 2017 in a vector. A leap year is a year which is divisible by 4 but NOT 100 but if the year is divisible by 100 then it must also be divisible by 400 to be considered a leap year.

You made a good start, all you need is to use indexing or concatenation to store the values that you want to keep, e.g.: lpy = ...

Starting from the year 1697, store all leap years until 2017 in a vector. A leap year is a year which is divisible by 4 but NOT 100 but if the year is divisible by 100 then it must also be divisible by 400 to be considered a leap year.

You made a good start, all you need is to use indexing or concatenation to store the values that you want to keep, e.g.: lpy = ...

3일 전 | 1

| 수락됨

답변 있음

How do I get two values of a function when using a loop?

You are only calling the function with one output argument. If the function returns two output arguments and you want both of th...

How do I get two values of a function when using a loop?

You are only calling the function with one output argument. If the function returns two output arguments and you want both of th...

3일 전 | 1

| 수락됨

답변 있음

vectorisation a for loop

Real vectorized code (no loop or arrayfun): eta = exp(-c*abs(bsxfun(@minus,dist,dist(:)))); discrim = 1./sum(eta,1) Or for MA...

vectorisation a for loop

Real vectorized code (no loop or arrayfun): eta = exp(-c*abs(bsxfun(@minus,dist,dist(:)))); discrim = 1./sum(eta,1) Or for MA...

3일 전 | 0

답변 있음

How to access object loaded into a struct when object variable name (as saved) is unknown

"I have tried every variation of indexing I can think of..." Indexing is entirely independent from fieldnames, so indexing like...

How to access object loaded into a struct when object variable name (as saved) is unknown

"I have tried every variation of indexing I can think of..." Indexing is entirely independent from fieldnames, so indexing like...

4일 전 | 0

| 수락됨

답변 있음

Collapsing nested cell array values into simple numerical array

"I have used regexp to find some numbers in each element of a cell array." If the regular expression only needs to match once, ...

Collapsing nested cell array values into simple numerical array

"I have used regexp to find some numbers in each element of a cell array." If the regular expression only needs to match once, ...

7일 전 | 0

| 수락됨

답변 있음

I really need help with fprintf'ing a string, having it alternate with commas and parentheses.

[~,idx] = ismember(coords,xy.','rows'); % Better: obtain these indices from your function! mat = [idx,coords].'; % should have ...

I really need help with fprintf'ing a string, having it alternate with commas and parentheses.

[~,idx] = ismember(coords,xy.','rows'); % Better: obtain these indices from your function! mat = [idx,coords].'; % should have ...

7일 전 | 0

| 수락됨

답변 있음

How to display the celcius sumbol (°C) using fprint??

Here are four methods: fid = fopen('temp.txt','wt'); fprintf(fid,'symbol one: °C\n'); fprintf(fid,'symbol two: %cC\n',176...

How to display the celcius sumbol (°C) using fprint??

Here are four methods: fid = fopen('temp.txt','wt'); fprintf(fid,'symbol one: °C\n'); fprintf(fid,'symbol two: %cC\n',176...

7일 전 | 2

| 수락됨

답변 있음

Values in cell array keep getting overwritten

Much simpler and much more robust: D = 'path to the main directory'; S = dir(fullfile(D,'img*')); for k = 1:numel(S) F =...

Values in cell array keep getting overwritten

Much simpler and much more robust: D = 'path to the main directory'; S = dir(fullfile(D,'img*')); for k = 1:numel(S) F =...

8일 전 | 1

| 수락됨

답변 있음

2D Convex Hull: I can't think of a 'criteria' to filter out the 'wrong' points, please help!

"I can't think of a 'criteria' to filter out the 'wrong' points." The obvious criteria to pick is in the name convex hull: why ...

2D Convex Hull: I can't think of a 'criteria' to filter out the 'wrong' points, please help!

"I can't think of a 'criteria' to filter out the 'wrong' points." The obvious criteria to pick is in the name convex hull: why ...

8일 전 | 0

답변 있음

Concatenate I x J*2 x K matrix in I*J x 2 x K matrix

Use reshape and permute, e.g. for two columns: >> A = randi(9,8,4,6); % fake data >> A(:,:,1) ans = 9 1 4 6 7 ...

Concatenate I x J*2 x K matrix in I*J x 2 x K matrix

Use reshape and permute, e.g. for two columns: >> A = randi(9,8,4,6); % fake data >> A(:,:,1) ans = 9 1 4 6 7 ...

8일 전 | 0

| 수락됨

답변 있음

How to use spacing around operator?

This is explained in the MATLAB documentation: https://www.mathworks.com/help/matlab/matlab_prog/case-and-space-sensitivity.htm...

How to use spacing around operator?

This is explained in the MATLAB documentation: https://www.mathworks.com/help/matlab/matlab_prog/case-and-space-sensitivity.htm...

8일 전 | 0

답변 있음

Finding maximum number location in a matrix

"Is there a reason why this line is wrong?" Yes, because you nested max inside find. Take a look at the output of max: what is ...

Finding maximum number location in a matrix

"Is there a reason why this line is wrong?" Yes, because you nested max inside find. Take a look at the output of max: what is ...

8일 전 | 0

| 수락됨

답변 있음

Vectorized implementation for using a vector as an index for matrices

Use sub2ind like this: >> m = 7; >> V = randi([1,10],1,m) V = 9 10 2 10 7 1 3 >> A = zeros(m,10)...

Vectorized implementation for using a vector as an index for matrices

Use sub2ind like this: >> m = 7; >> V = randi([1,10],1,m) V = 9 10 2 10 7 1 3 >> A = zeros(m,10)...

8일 전 | 0

| 수락됨

답변 있음

saving multiple .mat files with the same name from a script

"Is there any way it could be save as data1.mat, data2.mat ......data20.mat (if i run the script 20 times)..." You could downlo...

saving multiple .mat files with the same name from a script

"Is there any way it could be save as data1.mat, data2.mat ......data20.mat (if i run the script 20 times)..." You could downlo...

8일 전 | 0

답변 있음

If I have a logical vector created by ISDIR attribute of DIR, how to have its order by the date of the last modification of folders???

Simpler and much more robust: S = dir('D:\= BIO-PD ='); S = S([S.isdir] & ~ismember({S.name},{'.','..'})); % folders only, exc...

If I have a logical vector created by ISDIR attribute of DIR, how to have its order by the date of the last modification of folders???

Simpler and much more robust: S = dir('D:\= BIO-PD ='); S = S([S.isdir] & ~ismember({S.name},{'.','..'})); % folders only, exc...

10일 전 | 0

| 수락됨

답변 있음

How to find all letters before a character in a char variable

>> secretMes = [';,.T234h467e#i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n#i*895n#t$5&&h1/!i@$$s#f18945@i2/le#i98s#c`$%o%^n77*f(=i...

How to find all letters before a character in a char variable

>> secretMes = [';,.T234h467e#i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n#i*895n#t$5&&h1/!i@$$s#f18945@i2/le#i98s#c`$%o%^n77*f(=i...

10일 전 | 1

답변 있음

Data Sorting (looking for a range that do not exist in a list of numbers)

>> V = [1,2,3,6,7,8,23,24,25,76,77]; >> X = diff(V)~=1; >> B = V([X,false])+1 % missing range begin values B = 4 9 ...

Data Sorting (looking for a range that do not exist in a list of numbers)

>> V = [1,2,3,6,7,8,23,24,25,76,77]; >> X = diff(V)~=1; >> B = V([X,false])+1 % missing range begin values B = 4 9 ...

11일 전 | 0

답변 있음

Random shuffle vector such that all elements fall in new index positions

What you describe is called a derangement. You can download FEX submissions that perform derangements, e.g.: https://www.mathw...

Random shuffle vector such that all elements fall in new index positions

What you describe is called a derangement. You can download FEX submissions that perform derangements, e.g.: https://www.mathw...

12일 전 | 0

| 수락됨

답변 있음

Need to sort the number in the increasing order using MATLAB script, shown as a sample text file.

You could download my FEX submission natsort: https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-o...

Need to sort the number in the increasing order using MATLAB script, shown as a sample text file.

You could download my FEX submission natsort: https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-o...

12일 전 | 0