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

Answered
Shift data in row when NaNs occurs
>> M = [0.30,NaN,0.24,0.26,0.67,0.37;0.49,0.35,0.55,NaN,0.43,0.54] M = 0.30000 NaN 0.24000 0.26000 0.67000 0....

7 years ago | 0

| accepted

Answered
Reading Data from txt file with a unique FormatSpec
Method one: fileread and regexp and str2double: >> S = fileread('Test.txt'); >> M = reshape(str2double(regexp(S,'[+-]?\d*\.?\d...

7 years ago | 0

Answered
Directory Issue - not finding subfolder
"Any advice on how to approach this issue is appreciated." Do not use cd. Do not add data folders to the Search Path. Use abs...

7 years ago | 1

| accepted

Answered
filter string in the string
>> str = 'this matlab is a good software, it is a version 9.4 which is equal to 2018a'; >> out = regexp(str,'\d+\.\d+','match'...

7 years ago | 1

Answered
Store results of for loop in matrix
Use a cell array: N = numel(ab); out = cell(1,N); % preallocate cell array. for k = 1:N ... your code out{k} = Ncel...

7 years ago | 0

| accepted

Load more