5,726 total contributions since 2014

Suspensa Vix Via Fit

Answered

How can I import repeating blocks of mixed data as a table?

This imports and parses your example file: str = fileread('Data.txt'); str = regexprep(str,{'= ','[\r\n]+SNC','[\r\n]+'...

How can I import repeating blocks of mixed data as a table?

This imports and parses your example file: str = fileread('Data.txt'); str = regexprep(str,{'= ','[\r\n]+SNC','[\r\n]+'...

3 hours ago | 1

Answered

How to illustrate a cell array

There are no doubt many ways of doing this, one relatively intuitive way would be to use scatter. This should get you started (b...

How to illustrate a cell array

There are no doubt many ways of doing this, one relatively intuitive way would be to use scatter. This should get you started (b...

24 hours ago | 1

| accepted

Answered

How do I use sprintf with two variables with different sizes?

Assuming that you have nested structures, then you can easily do something like this: >> s(1).rawdata.data00 = 100; >> s(1).ra...

How do I use sprintf with two variables with different sizes?

Assuming that you have nested structures, then you can easily do something like this: >> s(1).rawdata.data00 = 100; >> s(1).ra...

1 day ago | 0

| accepted

Answered

Color and brightness in imread

Your image is actually an indexed image, not a grayscale image, and this is easy to find out using the inbuilt imfinfo: >> imfi...

Color and brightness in imread

Your image is actually an indexed image, not a grayscale image, and this is easy to find out using the inbuilt imfinfo: >> imfi...

2 days ago | 0

| accepted

Answered

How to remove everything from string except what's inside square brackets?

Where C is your cell array: >> D = regexp(C,'\[(.+)\]','tokens','once') >> D = vertcat(D{:}) D = 'rpm' 'rpm' ...

How to remove everything from string except what's inside square brackets?

Where C is your cell array: >> D = regexp(C,'\[(.+)\]','tokens','once') >> D = vertcat(D{:}) D = 'rpm' 'rpm' ...

5 days ago | 0

Answered

Exponent on top or on the right of the axis, control, turn off?

Either set the number format or the exponent: https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-l...

Exponent on top or on the right of the axis, control, turn off?

Either set the number format or the exponent: https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-l...

5 days ago | 1

| accepted

Answered

ismember(A,B,'rows') indexing

>> one = {'ADSµSOIC8';'AVX0603';'ELN';'ELNH10';'EPC';'EPC0603';'FAGDO214AA';'FAGDO214AA (SMB)';'FAGDO214AB';'FAGDO214AC';'FAGSMA...

ismember(A,B,'rows') indexing

>> one = {'ADSµSOIC8';'AVX0603';'ELN';'ELNH10';'EPC';'EPC0603';'FAGDO214AA';'FAGDO214AA (SMB)';'FAGDO214AB';'FAGDO214AC';'FAGSMA...

6 days ago | 1

| accepted

Answered

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in Untitled (line 23) D(i) = sqrt ((a1(i)-a9)^2 +(b1(i)-b9)^2 + (c

Using my trusty magical crystal ball: a1 = 550; b1 = 355; c1 = 0.5676; d1 = 1.3090; a9 = Data(:,1); b9 = Data(:,2); c9...

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in Untitled (line 23) D(i) = sqrt ((a1(i)-a9)^2 +(b1(i)-b9)^2 + (c

Using my trusty magical crystal ball: a1 = 550; b1 = 355; c1 = 0.5676; d1 = 1.3090; a9 = Data(:,1); b9 = Data(:,2); c9...

6 days ago | 1

Answered

Write a function called picker that takes three input arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns

function [cd,a,b]=picker(cd,a,b); if picker(a<b,a,b) fprintf('out=a'); else fprintf('out=b') end Your function ign...

Write a function called picker that takes three input arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns

function [cd,a,b]=picker(cd,a,b); if picker(a<b,a,b) fprintf('out=a'); else fprintf('out=b') end Your function ign...

6 days ago | 0

Answered

How can I make a single plot that consists of multiple lines, each made from every n rows of a vector?

"I'm sure I will need to use a loop because I won't be able to do this manually for a 300,000 x 2 set of data." I don't see why...

How can I make a single plot that consists of multiple lines, each made from every n rows of a vector?

"I'm sure I will need to use a loop because I won't be able to do this manually for a 300,000 x 2 set of data." I don't see why...

7 days ago | 0

| accepted

Answered

logaritmical spacing / incremented spacing

>> diff(fix(log2((1:32).'))) ans = 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ...

logaritmical spacing / incremented spacing

>> diff(fix(log2((1:32).'))) ans = 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ...

8 days ago | 1

| accepted

Answered

Transferring data from a cell array to a vector

"can i convert this data into vector?" >> Atlas = {122,12} ; >> vec = [Atlas{:}] vec = 122 12 https://www.mathworks.c...

Transferring data from a cell array to a vector

"can i convert this data into vector?" >> Atlas = {122,12} ; >> vec = [Atlas{:}] vec = 122 12 https://www.mathworks.c...

8 days ago | 0

Answered

Split string into string based on character type

>> S = '1A2'; >> C = regexp(S,'(\d+)(\D+)(\d+)','tokens','once') C = '1' 'A' '2'

Split string into string based on character type

>> S = '1A2'; >> C = regexp(S,'(\d+)(\D+)(\d+)','tokens','once') C = '1' 'A' '2'

8 days ago | 0

| accepted

Answered

How to append cell arrays with a very specific form

As long as your data meet some assumptions: each group contains exactly the same number of rows (four in your example), and ea...

How to append cell arrays with a very specific form

As long as your data meet some assumptions: each group contains exactly the same number of rows (four in your example), and ea...

8 days ago | 1

| accepted

Answered

Execute code faster for saving files with a matrix

"Any ideas how to run faster my code" Don't use xlswrite to write text files! Do not convert between data classes (e.g. do not...

Execute code faster for saving files with a matrix

"Any ideas how to run faster my code" Don't use xlswrite to write text files! Do not convert between data classes (e.g. do not...

8 days ago | 0

| accepted

Answered

Unexpected for loop behaviour

"Unexpected for loop behaviour" The value -0.1 cannot be represented exactly using floating point numbers, and you could quite ...

Unexpected for loop behaviour

"Unexpected for loop behaviour" The value -0.1 cannot be represented exactly using floating point numbers, and you could quite ...

8 days ago | 1

| accepted

Answered

random numbers without repetition of two consecutive numbers

Adapting John D'Errico's answer to an earlier question: >> n = 5; >> k = 4; >> t = 100; >> 1+mod(cumsum([randi(k,t,1),randi(...

random numbers without repetition of two consecutive numbers

Adapting John D'Errico's answer to an earlier question: >> n = 5; >> k = 4; >> t = 100; >> 1+mod(cumsum([randi(k,t,1),randi(...

9 days ago | 4

Answered

Finding length of a struct, excluding NaN values

You can do this very easily with the accepted answer to your very similar question from two months ago: https://www.mathworks.c...

Finding length of a struct, excluding NaN values

You can do this very easily with the accepted answer to your very similar question from two months ago: https://www.mathworks.c...

9 days ago | 2

| accepted

Answered

How to Overwrite Data

One simple MATLAB way: C = max(A,B).*(B~=0) Or for MATLAB versions prior to R2016b: C = bsxfun(@max,A,B).*(B~=0)

How to Overwrite Data

One simple MATLAB way: C = max(A,B).*(B~=0) Or for MATLAB versions prior to R2016b: C = bsxfun(@max,A,B).*(B~=0)

9 days ago | 0

| accepted

Answered

Does findpeaks work with mat files?

Most likely you need to actually refer to the structure that you imported the file data into: S = load('mytrace2131soma&syns.ma...

Does findpeaks work with mat files?

Most likely you need to actually refer to the structure that you imported the file data into: S = load('mytrace2131soma&syns.ma...

12 days ago | 0

Answered

Read only numbers from string

"Given a string, how to read only the numbers?" That really depends on what you define as being a "numberˇ: which of these are ...

Read only numbers from string

"Given a string, how to read only the numbers?" That really depends on what you define as being a "numberˇ: which of these are ...

12 days ago | 0

| accepted

Answered

help to use for loop in four layer

Without loops: >> [X,Y,Z] = ndgrid(1:3); >> A = permute(cat(3,p(:,Z),ommega(:,Y),v(:,X)),[1,3,2]); And checking with some exa...

help to use for loop in four layer

Without loops: >> [X,Y,Z] = ndgrid(1:3); >> A = permute(cat(3,p(:,Z),ommega(:,Y),v(:,X)),[1,3,2]); And checking with some exa...

12 days ago | 1

| accepted

Answered

Putting Consecutive numbers into variables

>> A = [1;2;3;7;0;6;7;8;9;2;4;3;14;15;16;17;0;9;2]; >> D = diff([false;diff(A(:))==1;false]); >> F = @(b,e)A(b:e); >> C = arr...

Putting Consecutive numbers into variables

>> A = [1;2;3;7;0;6;7;8;9;2;4;3;14;15;16;17;0;9;2]; >> D = diff([false;diff(A(:))==1;false]); >> F = @(b,e)A(b:e); >> C = arr...

13 days ago | 0

| accepted

Submitted

Maximally Distinct Color Generator

Generate truly maximally distinct colors in an RGB colormap.

13 days ago | 21 downloads |

Submitted

Convert between RGB and Color Names

RGB to color name. Color name to RGB. Palettes: CSS, HTML, MATLAB, SVG, X11, xcolor, xkcd,...

13 days ago | 23 downloads |

Answered

Meet multiple conditions (or)

Use ismember: ismember(peroxi_3d_lab,your_conditions_array) Tip: with MATLAB it is always important to think in terms of opera...

Meet multiple conditions (or)

Use ismember: ismember(peroxi_3d_lab,your_conditions_array) Tip: with MATLAB it is always important to think in terms of opera...

13 days ago | 0

| accepted

Answered

Use one matrix to change values of another

Method one: indexing: >> X = ismember(B,A) >> B(~X) = 0 B = 1 2 3 4 0 0 0 0 1 2 ...

Use one matrix to change values of another

Method one: indexing: >> X = ismember(B,A) >> B(~X) = 0 B = 1 2 3 4 0 0 0 0 1 2 ...

13 days ago | 1

| accepted

Answered

regex: Extract then delete

"Is there a regex function that can extract matched strings and delete them after?" Not really. You could do something like th...

regex: Extract then delete

"Is there a regex function that can extract matched strings and delete them after?" Not really. You could do something like th...

13 days ago | 0

| accepted

Answered

Using a matrix as pairs of indexes of another matrix

"How can this be done without a loop?" Using sub2ind, which converts to linear indices: >> ind = sub2ind(size(x),idx(:,1),idx(...

Using a matrix as pairs of indexes of another matrix

"How can this be done without a loop?" Using sub2ind, which converts to linear indices: >> ind = sub2ind(size(x),idx(:,1),idx(...

13 days ago | 0

| accepted