42,881 total contributions since 2011

I do not do free private consulting. If you want to bring my attention to something, send a link to the MATLAB Answers location.

Answered

Why do I get this error since there is only one function?

This happens when a script file with that name contains a function definition with the same name. Which can also happen in what ...

Why do I get this error since there is only one function?

This happens when a script file with that name contains a function definition with the same name. Which can also happen in what ...

3 hours ago | 1

Answered

Many functions in a large script file

"I am wondered how can I add nested functions in a parent function in a while loop. Is that possible?" No. functions cannot be ...

Many functions in a large script file

"I am wondered how can I add nested functions in a parent function in a while loop. Is that possible?" No. functions cannot be ...

9 hours ago | 0

| accepted

Answered

cannot call m-file in another m-file

y = 2x + 3; 2x is not a valid variable name in MATLAB, and it is not a valid way to write a number in MATLAB. Like the error m...

cannot call m-file in another m-file

y = 2x + 3; 2x is not a valid variable name in MATLAB, and it is not a valid way to write a number in MATLAB. Like the error m...

9 hours ago | 1

| accepted

Answered

Clustering Calculating total value

C1 = C(1,1:2); C2 = C(1, 3:4); X = YourArray - C1;

Clustering Calculating total value

C1 = C(1,1:2); C2 = C(1, 3:4); X = YourArray - C1;

11 hours ago | 0

Answered

Solver execution time is very slow.

tic syms a1 a2 a3 eqns = [a1 + 0.01 * (a2 + a3) - 5, a2 + 0.01 * (a1 + a3) - 6, a3 + 0.01 * (a2 + a1) - 7]; sol = solve(eqns,...

Solver execution time is very slow.

tic syms a1 a2 a3 eqns = [a1 + 0.01 * (a2 + a3) - 5, a2 + 0.01 * (a1 + a3) - 6, a3 + 0.01 * (a2 + a1) - 7]; sol = solve(eqns,...

11 hours ago | 0

Answered

Inquiry MISRA C 2012 6.1

You have a problem. http://port70.net/~nsz/c/c89/c89-draft.html#3.5.2.1 A bit-field may have type int , unsigned int , or sig...

Inquiry MISRA C 2012 6.1

You have a problem. http://port70.net/~nsz/c/c89/c89-draft.html#3.5.2.1 A bit-field may have type int , unsigned int , or sig...

11 hours ago | 0

Answered

how to take mean of every second data in a minute and an hourly?

TT2 = retime(TT1, 'minute', @std);

how to take mean of every second data in a minute and an hourly?

TT2 = retime(TT1, 'minute', @std);

11 hours ago | 1

Answered

How do I convert to Mex from Cpp using Xcode ver 10

Your SegmentBoneDP.cpp file is the source code. If you need something that converts C++ code into MATLAB code, then you are usi...

How do I convert to Mex from Cpp using Xcode ver 10

Your SegmentBoneDP.cpp file is the source code. If you need something that converts C++ code into MATLAB code, then you are usi...

14 hours ago | 1

| accepted

Answered

How to solve a system of two non-linear equations symbolically

sol = solve(L0 -1 +a*L1^(a-1) -a*A*L0^(a-1)==0, L1 -1 -a*L1^(a-1) +a*A*L0^(a-1)==0,'returnconditions',true); sol = stru...

How to solve a system of two non-linear equations symbolically

sol = solve(L0 -1 +a*L1^(a-1) -a*A*L0^(a-1)==0, L1 -1 -a*L1^(a-1) +a*A*L0^(a-1)==0,'returnconditions',true); sol = stru...

15 hours ago | 1

Answered

How to show the legends of this plot?

Record the handles of the objects you are going to produce legend() entries for. Pass those handles to legend() as the first par...

How to show the legends of this plot?

Record the handles of the objects you are going to produce legend() entries for. Pass those handles to legend() as the first par...

1 day ago | 1

Answered

How to fix MATLAB errors arise from changing the search path?

"I usually saved my projects in C:\Program Files\MATLAB\R2016a\bin" You have corrupted MATLAB . You need to move your projects ...

How to fix MATLAB errors arise from changing the search path?

"I usually saved my projects in C:\Program Files\MATLAB\R2016a\bin" You have corrupted MATLAB . You need to move your projects ...

1 day ago | 0

Answered

How do I change the color of the markers in the legend in a scatter plot with colormap?

Most of the time, using legend() together with scatter() will not give you the results you want. The work-around is to deliber...

How do I change the color of the markers in the legend in a scatter plot with colormap?

Most of the time, using legend() together with scatter() will not give you the results you want. The work-around is to deliber...

1 day ago | 0

Answered

Leave out dot notation in table variables

The closest MATLAB equivalent is import but it only applies for packages https://www.mathworks.com/help/matlab/matlab_oop/scopin...

Leave out dot notation in table variables

The closest MATLAB equivalent is import but it only applies for packages https://www.mathworks.com/help/matlab/matlab_oop/scopin...

1 day ago | 0

Answered

How to copy every 500 rows to a new variable?

result = squeeze(cellfun(@transpose, num2cell(reshape(YourMatrix.', size(YourMatrix,2), 500, []), [1 2]), 'uniform', 0)); This ...

How to copy every 500 rows to a new variable?

result = squeeze(cellfun(@transpose, num2cell(reshape(YourMatrix.', size(YourMatrix,2), 500, []), [1 2]), 'uniform', 0)); This ...

1 day ago | 0

Answered

how to take mean of every second data in a minute and an hourly?

We recommend creating timetable() and using the retime() function.

how to take mean of every second data in a minute and an hourly?

We recommend creating timetable() and using the retime() function.

1 day ago | 1

| accepted

Answered

Error: Function definitions are not permitted in this context.

It is never valid to copy and paste a "function" definition to the command line. It is also not valid to eval() a character vect...

Error: Function definitions are not permitted in this context.

It is never valid to copy and paste a "function" definition to the command line. It is also not valid to eval() a character vect...

1 day ago | 0

| accepted

Answered

How can we start different sessions simultaneously?

"Is there a way to start two different sessions simultaneously?" No. And parfor or spmd will not help for this purpose. Startin...

How can we start different sessions simultaneously?

"Is there a way to start two different sessions simultaneously?" No. And parfor or spmd will not help for this purpose. Startin...

1 day ago | 0

Answered

How to remove a particular frequency in the fft code?

[~, idx] = min(abs(f - 10.1)); %which bin is closest to 10.1 ? Y(idx) = 0; %zero that bin Y(end-idx+2) = 0; %zer...

How to remove a particular frequency in the fft code?

[~, idx] = min(abs(f - 10.1)); %which bin is closest to 10.1 ? Y(idx) = 0; %zero that bin Y(end-idx+2) = 0; %zer...

1 day ago | 0

| accepted

Answered

How to Give Column Names to MATLAB Table Dynamically

Column names must be valid matlab variable names. colnames = "AD" + T; The AD can be changed to any valid prefix of a var...

How to Give Column Names to MATLAB Table Dynamically

Column names must be valid matlab variable names. colnames = "AD" + T; The AD can be changed to any valid prefix of a var...

1 day ago | 0

| accepted

Answered

Using Textscan on non-uniform data

fid = fopen('HS_full_18md_nam_outputs.txt'); fgets(fid); %skip header ctl = fscanf(fid, '%f%f', 2); Nt = ctl(1); Ns = ctl(...

Using Textscan on non-uniform data

fid = fopen('HS_full_18md_nam_outputs.txt'); fgets(fid); %skip header ctl = fscanf(fid, '%f%f', 2); Nt = ctl(1); Ns = ctl(...

2 days ago | 1

Answered

How should I randomly generate pairs of non-identical natural numbers that should also be non-repeating?

[A, B] = ndgrid(range); mask = A==B; A(mask) = []; B(mask) = []; N = length(A); p = randperm(N, 20); pairs = [A(p); B(p)].'...

How should I randomly generate pairs of non-identical natural numbers that should also be non-repeating?

[A, B] = ndgrid(range); mask = A==B; A(mask) = []; B(mask) = []; N = length(A); p = randperm(N, 20); pairs = [A(p); B(p)].'...

2 days ago | 1

| accepted

Answered

How can I only keep keys that have the smallest value pair in a matrix?

[g, val] = findgroups(A(:,1)); B = [val, accumarray(g, A(:,2), [], @min)];

How can I only keep keys that have the smallest value pair in a matrix?

[g, val] = findgroups(A(:,1)); B = [val, accumarray(g, A(:,2), [], @min)];

2 days ago | 0

Answered

Setpath error: the path file pathdef.m might be read only

MATLAB generally creates a writeable pathdef.m when it is installed, but not always. Sometimes pathdef.m ends up in a directory ...

Setpath error: the path file pathdef.m might be read only

MATLAB generally creates a writeable pathdef.m when it is installed, but not always. Sometimes pathdef.m ends up in a directory ...

2 days ago | 0

Answered

install App with image-component in older version Matlab

uiimage() cannot be used in any release before R2019a.

install App with image-component in older version Matlab

uiimage() cannot be used in any release before R2019a.

2 days ago | 0

Answered

What is the max image size Matlab OCR can process

"What is the largest size image Matlab's OCR can process?" 140737488355327 bytes. Call it 6 1/2 million by 6 1/2 million RGB.

What is the max image size Matlab OCR can process

"What is the largest size image Matlab's OCR can process?" 140737488355327 bytes. Call it 6 1/2 million by 6 1/2 million RGB.

2 days ago | 0

| accepted

Answered

loading excel cell in matlab

vel_data=dir('*.mat'); so vel_data contains information about .mat files WL_data=dir('*.xlsx'); so WL_data contains informati...

loading excel cell in matlab

vel_data=dir('*.mat'); so vel_data contains information about .mat files WL_data=dir('*.xlsx'); so WL_data contains informati...

2 days ago | 0

Answered

How do I explain the random functions to my professor?

"Also, it will be different from picking one value each from A,B,C for 5 times compared to picking all 5 from A, then moving on ...

How do I explain the random functions to my professor?

"Also, it will be different from picking one value each from A,B,C for 5 times compared to picking all 5 from A, then moving on ...

2 days ago | 4

Answered

What is the meaning of following code?

size(Residuals,1) is the number of rows in the Residuals array. 1:2:size(Residuals,1) is the odd-numbered rows. [1:2:size(Residu...

What is the meaning of following code?

size(Residuals,1) is the number of rows in the Residuals array. 1:2:size(Residuals,1) is the odd-numbered rows. [1:2:size(Residu...

3 days ago | 0

| accepted

Answered

I have IgorTime data in which time:units = "seconds since 1904-01-01". I would like to convert this seconds to datevc.

datetime(T/86400,'convertfrom','excel1904')

I have IgorTime data in which time:units = "seconds since 1904-01-01". I would like to convert this seconds to datevc.

datetime(T/86400,'convertfrom','excel1904')

3 days ago | 1

| accepted