6.036 total contributions since 2014

Suspensa Vix Via Fit

Answered

How do I locate all integer values within a matrix (of string and integer values in the same cell), then replace all those integer values with a 1 or 0 thus forming a new matrix with the replaced integers?

Method one: multiple regular expressions in one regexprep call: >> c = {'( x(2) | x(1) )', 'x(3)', '( x(4) | x(6) | x(5) )', '(...

How do I locate all integer values within a matrix (of string and integer values in the same cell), then replace all those integer values with a 1 or 0 thus forming a new matrix with the replaced integers?

Method one: multiple regular expressions in one regexprep call: >> c = {'( x(2) | x(1) )', 'x(3)', '( x(4) | x(6) | x(5) )', '(...

2 giorni ago | 1

Answered

Averaging 30 arrays into one using function

Do not create lots of separate variables or arrays, just use the split-apply process: https://www.mathworks.com/help/matlab/mat...

Averaging 30 arrays into one using function

Do not create lots of separate variables or arrays, just use the split-apply process: https://www.mathworks.com/help/matlab/mat...

2 giorni ago | 0

Answered

Dont know how to name this...

MATLAB only accepts decimal point , and does NOT accept a decimal comma. When you write a comma you are writing two separate va...

Dont know how to name this...

MATLAB only accepts decimal point , and does NOT accept a decimal comma. When you write a comma you are writing two separate va...

2 giorni ago | 1

| accepted

Answered

Please help me to understand Error "The expression to the left of the equals sign is not a valid target for an assignment.

The problem is your invented syntax using { and }, which looks like you are trying to write code using a different programming l...

Please help me to understand Error "The expression to the left of the equals sign is not a valid target for an assignment.

The problem is your invented syntax using { and }, which looks like you are trying to write code using a different programming l...

3 giorni ago | 2

| accepted

Answered

How to read specific parts of file and then write it to a text file?

This imports all of the "TEC MAP" data from the file you uploaded: str = fileread('codg1520.14i'); % Functions to convert text...

How to read specific parts of file and then write it to a text file?

This imports all of the "TEC MAP" data from the file you uploaded: str = fileread('codg1520.14i'); % Functions to convert text...

3 giorni ago | 0

| accepted

Submitted

MatPlotLib Perceptually Uniform Colormaps

MatPlotLib's default perceptually uniform colormap VIRIDIS and distinctive ColorOrder TAB10/VEGA10

3 giorni ago | 66 downloads |

Answered

Minimum value of loop

>> N = 3; >> a = Inf; >> for k = 1:N, a = min(a,k+2); end >> a a = 3

Minimum value of loop

>> N = 3; >> a = Inf; >> for k = 1:N, a = min(a,k+2); end >> a a = 3

4 giorni ago | 0

| accepted

Answered

How to concatenate all these cells vertically?

>> load('matlab.mat') >> R = S.result; >> T = vertcat(R{:}); >> whos T Name Size Bytes Class Attr...

How to concatenate all these cells vertically?

>> load('matlab.mat') >> R = S.result; >> T = vertcat(R{:}); >> whos T Name Size Bytes Class Attr...

4 giorni ago | 1

| accepted

Answered

Creating a tridiagonal matrix

"My teacher has said that the best way to go about it is using loops" Why on earth would they say that? Either diag : >> N = 1...

Creating a tridiagonal matrix

"My teacher has said that the best way to go about it is using loops" Why on earth would they say that? Either diag : >> N = 1...

5 giorni ago | 1

Answered

split a string by a set of pre-defined number of characters rather than any delimiter

You could do that using regular expressions: >> S1 = ' 961.666 - Psat 1.0000 45.0971 3.6734';...

split a string by a set of pre-defined number of characters rather than any delimiter

You could do that using regular expressions: >> S1 = ' 961.666 - Psat 1.0000 45.0971 3.6734';...

8 giorni ago | 0

| accepted

Answered

removing non prime number function

str = fileread('temp.txt'); vec = str2double(regexp(str,'\d+','match')) [fid,msg] = fopen('output.txt','wt'); assert(fid>=3,m...

removing non prime number function

str = fileread('temp.txt'); vec = str2double(regexp(str,'\d+','match')) [fid,msg] = fopen('output.txt','wt'); assert(fid>=3,m...

8 giorni ago | 0

Answered

Repeat the value of a variable to match the length of another variable

>> X = 'TESTING'; >> Y = 'WORLD'; >> Z = Y(1+mod(0:numel(X)-1,numel(Y))) Z = WORLDWO

Repeat the value of a variable to match the length of another variable

>> X = 'TESTING'; >> Y = 'WORLD'; >> Z = Y(1+mod(0:numel(X)-1,numel(Y))) Z = WORLDWO

8 giorni ago | 0

Answered

Substract Matrix coloum-wise from Matrix without using a loop

permute lets you do this on one line: D = min(sqrt(sum(bsxfun(@minus,permute(A,[1,3,2]),permute(B,[3,1,2])).^2,3)),[],1); And ...

Substract Matrix coloum-wise from Matrix without using a loop

permute lets you do this on one line: D = min(sqrt(sum(bsxfun(@minus,permute(A,[1,3,2]),permute(B,[3,1,2])).^2,3)),[],1); And ...

8 giorni ago | 0

| accepted

Answered

Is MATLAB confusing functions and arrays?

"Is MATLAB confusing functions and arrays?" That can happen in certain circumstances, but that does not seem to be the case her...

Is MATLAB confusing functions and arrays?

"Is MATLAB confusing functions and arrays?" That can happen in certain circumstances, but that does not seem to be the case her...

9 giorni ago | 1

| accepted

Answered

Storing user inputs during while loop, in a vector

x = []; while ... x(end+1) = input(prompt); end

Storing user inputs during while loop, in a vector

x = []; while ... x(end+1) = input(prompt); end

10 giorni ago | 0

Answered

find elements vector in a matrix

Simply use sub2ind like this: >> idx = sub2ind(size(psic_pos),1:size(psic_pos,1),loc); >> vec = psic_pos(idx) vec = 0....

find elements vector in a matrix

Simply use sub2ind like this: >> idx = sub2ind(size(psic_pos),1:size(psic_pos,1),loc); >> vec = psic_pos(idx) vec = 0....

10 giorni ago | 1

| accepted

Answered

find 4d matrix positions

"I tried with ind2sub but it was useless." It worked for me. First lets define some fake data: >> A = zeros(5,4,3,2); >> A(5,...

find 4d matrix positions

"I tried with ind2sub but it was useless." It worked for me. First lets define some fake data: >> A = zeros(5,4,3,2); >> A(5,...

10 giorni ago | 0

| accepted

Answered

import data without header

opt = {'HeaderLines',20}; fmt = repmat('%f',1,4); str = fileread('temp0.txt'); C = textscan(strrep(str,',','.'),fmt,opt{:}); ...

import data without header

opt = {'HeaderLines',20}; fmt = repmat('%f',1,4); str = fileread('temp0.txt'); C = textscan(strrep(str,',','.'),fmt,opt{:}); ...

10 giorni ago | 0

| accepted

Answered

Extract number from file name

>> C = {'K10_0.0.json', 'Mig_Thresh_2.0.json', 'K_5_6.5.json', 'WC_0.00051.json'}; >> [~,N] = cellfun(@fileparts,C,'uni',0); >...

Extract number from file name

>> C = {'K10_0.0.json', 'Mig_Thresh_2.0.json', 'K_5_6.5.json', 'WC_0.00051.json'}; >> [~,N] = cellfun(@fileparts,C,'uni',0); >...

11 giorni ago | 1

Answered

Switch function to output number of days in a month

Actually you need to use the optional 's' argument for input, otherwise your code will throw an error: n = input('Enter the mon...

Switch function to output number of days in a month

Actually you need to use the optional 's' argument for input, otherwise your code will throw an error: n = input('Enter the mon...

12 giorni ago | 0

| accepted

Answered

How to solve Reference to non-existent field 'folder'.

The folder field (and recursive folder searching) was added in R2016b. As you are not using the recursive folder search you can...

How to solve Reference to non-existent field 'folder'.

The folder field (and recursive folder searching) was added in R2016b. As you are not using the recursive folder search you can...

12 giorni ago | 0

Answered

Sort the dir loaded files

Download my FEX submission natsortfiles and follow the examples in its documentation: https://www.mathworks.com/matlabcentral/f...

Sort the dir loaded files

Download my FEX submission natsortfiles and follow the examples in its documentation: https://www.mathworks.com/matlabcentral/f...

13 giorni ago | 0

Answered

Changing the ASCII sort order format?

To sort filenames into the order that you want download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral...

Changing the ASCII sort order format?

To sort filenames into the order that you want download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral...

13 giorni ago | 0

Answered

Table format issue with fprintf command

>> fprintf('%9.2f in%9.2f in^2%9.2f in^3\n',[r;S;V]) 0.00 in 0.00 in^2 0.00 in^3 0.25 in 0.79 in^2 0...

Table format issue with fprintf command

>> fprintf('%9.2f in%9.2f in^2%9.2f in^3\n',[r;S;V]) 0.00 in 0.00 in^2 0.00 in^3 0.25 in 0.79 in^2 0...

15 giorni ago | 0

Answered

Duplicate Each Element in a Matrix without using Repelem or Repmat

>> A = [1,0;0,1] A = 1 0 0 1 >> V = ceil((1:6)/3); >> B = A(V,V) B = 1 1 1 0 0 0 1 1 1 0...

Duplicate Each Element in a Matrix without using Repelem or Repmat

>> A = [1,0;0,1] A = 1 0 0 1 >> V = ceil((1:6)/3); >> B = A(V,V) B = 1 1 1 0 0 0 1 1 1 0...

15 giorni ago | 2

Answered

Can anyone help? I cannot figure out how to use a for loop to check elements in part of a matrix.

"I can make the actual matrix, but after that I don't know what comes next." Your assignment tells you exactly what you need to...

Can anyone help? I cannot figure out how to use a for loop to check elements in part of a matrix.

"I can make the actual matrix, but after that I don't know what comes next." Your assignment tells you exactly what you need to...

16 giorni ago | 0

| accepted

Answered

Indexing into a type I don't recognize

Use indexing to get any elements you want from a structure array: ext_header(ii).value https://www.mathworks.com/help/matlab/m...

Indexing into a type I don't recognize

Use indexing to get any elements you want from a structure array: ext_header(ii).value https://www.mathworks.com/help/matlab/m...

16 giorni ago | 0

| accepted

Answered

Dimensions of arrays being concatenated are not consistent

You included definitions for every variable except for the one that likely causes the problem, I0. Running your code gives an e...

Dimensions of arrays being concatenated are not consistent

You included definitions for every variable except for the one that likely causes the problem, I0. Running your code gives an e...

17 giorni ago | 0

| accepted

Answered

Is there a command ( like "sort" for example ) arranges vector elements ascending ,max, descending (humped shap)?

>> V = randi(99,1,23) V = 93 68 76 74 39 65 17 70 4 28 5 10 82 69 32 95 ...

Is there a command ( like "sort" for example ) arranges vector elements ascending ,max, descending (humped shap)?

>> V = randi(99,1,23) V = 93 68 76 74 39 65 17 70 4 28 5 10 82 69 32 95 ...

19 giorni ago | 0

| accepted

Answered

Delimiter problems with =

opt = {'Delimiter','='}; fmt = '%s%[^\n]'; [fid,msg] = fopen('ENTRADA.txt','rt'); assert(fid>=3,msg) C = textscan(fid,fmt,op...

Delimiter problems with =

opt = {'Delimiter','='}; fmt = '%s%[^\n]'; [fid,msg] = fopen('ENTRADA.txt','rt'); assert(fid>=3,msg) C = textscan(fid,fmt,op...

19 giorni ago | 1

| accepted