Answered
How to remove letters from cell arrays
Why do you need to delete them? >> str = '2019-08-20T13:58:31Z'; >> datevec(str,'yyyy-mm-ddTHH:MM:SS') ans = 2019 ...

7 years ago | 1

| accepted

Answered
How do I use nargin to differentiate between a default units setting and unit input from function call
Replace units = 'm'; with if nargin<4 units = 'm'; end

7 years ago | 0

| accepted

Answered
How to track elements in a matrix that switch their position when converting into another matrix?
>> A = [1,2,3,4,5,6,7,8,9,10;1,2,3,4,5,6,7,8,9,10]; >> B = [1,1,1,1,2,3,4,5,6,7;1,1,1,1,1,1,1,1,2,3]; >> C = [6,7,8,9,10,10,10...

7 years ago | 1

| accepted

Answered
Arrays exercise Maximum and Minimum values
>> B = nonzeros(A(:)); >> M = bsxfun(@minus,B,B.'); >> V = abs(M(~eye(numel(B)))); >> max(V) ans = 5 >> min(V) ans = 1

7 years ago | 0

Answered
row vector and column vector addition
"I should get an error right?" Not since R2016b: https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r20...

7 years ago | 3

| accepted

Answered
Sampling iteratively random value from a matrix/array
No loops required, just use indexing: k = 1:13; % fake data n = numel(k); rl = [0.7 0.8 0.85 0.95 1] rs = [0.65 0.7 0.75 0.8...

7 years ago | 1

| accepted

Answered
Confused with the switch-case outputs with nargin
"Why the function chooses the second case to execute?" Because that is exactly what you wrote your functions to do. You call b...

7 years ago | 1

Answered
k- in the Borders function written by Chad Greene
https://www.mathworks.com/help/matlab/ref/linespec.html 'k' black color '-' continuous line (i.e. not dots or dashes)

7 years ago | 0

| accepted

Answered
Error: The expression to the left of the equals sign is not a valid target for an assignment.
As Walter Roberson already wrote, the problem is most likely caused by unmatched curly braces or square brackets earlier in the ...

7 years ago | 1

| accepted

Answered
How to find out the value of a matrix corresponding row and column?
Use sub2ind: >> x = [1;2;3]; >> y = [1;1;2]; >> z = [0,4;5,6;1,0]; >> z(sub2ind(size(z),x,y)) ans = 0 5 0...

7 years ago | 2

| accepted

Answered
How do I see the variables in base workspace when I am in a function?
Method 3: dbup and dbdown.

7 years ago | 0

Answered
Audioplayer object not passed into callback function
The problem is your definition of the callback as a character vector: player.StartFcn = 'audiocallbacktest' Defining callbacks...

7 years ago | 2

| accepted

Answered
String Vector for-loop
>> str = {'a1','a2','a3','b1','b2','b3'}; >> vec = sscanf([str{:}],'%*[ab]%f',[1,Inf]) vec = 1 2 3 1 2 3 >> vec = str...

7 years ago | 0

| accepted

Answered
Calculate the number of nonzero rows
>> nnz(any(B,2)) ans = 2

7 years ago | 3

| accepted

Answered
Solve systems of linear equations Ax = B for x
"But ,what is the operation between the rows?" Both mldivide and mrdivide can use many different algorithms for solving systems...

7 years ago | 0

| accepted

Answered
Calling evalin with three arguments
The third (as far as I can tell) totally undocumented input argument provides a default value if a specific variable is not foun...

7 years ago | 0

| accepted

Answered
How do I check if a folder exists which has a variable name?
[~,name] = fileparts(fname); exist(fullfile('Figures',name), 'dir')~=7 Note that exist does NOT return a boolean value, it ret...

7 years ago | 1

| accepted

Answered
Function definition is misplaced or improperly nested error
Once the code is aligned properly then the problem is clear: for ... for ... for ... for ... ...

7 years ago | 0

| accepted

Answered
Apply hold on to multiple figures in a loop
"how to apply the "hold on" to each figure" The properties affected by hold are all axes properties, which have nothing to do w...

7 years ago | 0

| accepted

Answered
Trying to request user input and then perform if elseif else end function...
"...which is the best way to create an empty output for storing text info..." Use a cell array or a string array, e.g.: out = ...

7 years ago | 0

| accepted

Answered
Change line colour depending on y axis value
Method one: FEX Some of these might do what you want: https://www.mathworks.com/matlabcentral/fileexchange/39972-colormapline-...

7 years ago | 0

Answered
Loop to generate random numbers and compile results for each iterations
You could easily use a cell array: N = 100; Z = cell(1,N); for k = 1:N ... your code Z{k} = whatever you want to st...

7 years ago | 0

| accepted

Answered
How to sort matrix based on another matrix?
>> A = [3,2,1;8,3,1;6,4,2] A = 3 2 1 8 3 1 6 4 2 >> B = [5,9,2;9,2,1;8,7,4] B = 5 9 2 9 2 1 8 7 ...

7 years ago | 0

| accepted

Answered
Get variable name into filename using strcat
Nowhere do you describe/show what the output filename should look like, but this should get you started: >> sno = 5100; >> inp...

7 years ago | 0

| accepted

Answered
Replacing strings with varying length and numbers
>> str = 'Phase1_525kV_4km_100m_0.5ohm'; >> out = regexprep(str,'\d+\.?\d*[a-zA-Z]+','X') out = Phase1_X_X_X_X

7 years ago | 0

| accepted

Answered
How do I speed up plotting of interactable scatter points?
Actually one single plot or line call can generate multiple line objects even if each one line only contains one point, the tric...

7 years ago | 0

| accepted

Answered
permutations of a matrix
Based on this efficient concept for generating a matrix of binary combinations: https://www.mathworks.com/matlabcentral/fileexc...

7 years ago | 1

| accepted

Answered
How to Scale Array Indices to larger array indices?
Here is one simple approach based on diff and find. Because a scaling factor of 68608 is rather inconvenient I used a scaling f...

7 years ago | 0

| accepted

Answered
str2num strange behaviour
"str2num strange behaviour" It is not strange behavior at all: str2num (unfortunately) relies on eval, as the str2num help clea...

7 years ago | 1

| accepted

Answered
How to extract data from a multi layered structure
"How can i calculate the minimum of a given field (min_temp for example) ?" You do not define what "the minimum" means for mul...

7 years ago | 0

Load more