12,527 total contributions since 2009

It is easier to solve a problem than to guess, what the problem is.

Questions about FileExchange submissions are welcome - get my address from the code. I do not answer mails concerning questions in the forum.

Answered

Can I construct a matrix multiplying a scalar and a vector?

No, tis is not a standard multiplication. But you can create k based on i and j: i = 3; j = [4; 5]; % Solution 1: k(:, 2) ...

Can I construct a matrix multiplying a scalar and a vector?

No, tis is not a standard multiplication. But you can create k based on i and j: i = 3; j = [4; 5]; % Solution 1: k(:, 2) ...

9 days ago | 1

| accepted

Answered

How can I maximize a function in Matlab?

Matlab contains some tools for minimization. A maximization does exactlly the same, if you change the sign of the optimization c...

How can I maximize a function in Matlab?

Matlab contains some tools for minimization. A maximization does exactlly the same, if you change the sign of the optimization c...

11 days ago | 1

| accepted

Answered

How do I access a certain directory?

You can define the path of a file to access it: Folder = 'C:\Temp\'; FileList = dir(fullfile(Folder, '*.jpg')); for iFile = 1...

How do I access a certain directory?

You can define the path of a file to access it: Folder = 'C:\Temp\'; FileList = dir(fullfile(Folder, '*.jpg')); for iFile = 1...

11 days ago | 2

Answered

how can i solve this ,can anyone provide me with code? whats wrong with my code ?

function valid = valid_date(year, month, day) % scalar positive integer limit if isscalar(year...

how can i solve this ,can anyone provide me with code? whats wrong with my code ?

function valid = valid_date(year, month, day) % scalar positive integer limit if isscalar(year...

14 days ago | 3

Answered

i wanted the slope with respect to time frame

Maybe all you need is to call the gradient(X.') function, where X is the complete matrix?

i wanted the slope with respect to time frame

Maybe all you need is to call the gradient(X.') function, where X is the complete matrix?

16 days ago | 1

Answered

Efficient way to rename files adding prefix from higher rank folder

% Assuming that the Subject_folder's are contained in D:\Your\Folder\ : BasePath = 'D:\Your\Folder\'; BaseLen = length(BasePa...

Efficient way to rename files adding prefix from higher rank folder

% Assuming that the Subject_folder's are contained in D:\Your\Folder\ : BasePath = 'D:\Your\Folder\'; BaseLen = length(BasePa...

16 days ago | 0

Answered

Save figure as jpg with 600dpi

saveas('figure.jpg') The first input must be the handle of a figure. print(gcf, 'figure.jpg', '-jpg', '-r600'); There is no '...

Save figure as jpg with 600dpi

saveas('figure.jpg') The first input must be the handle of a figure. print(gcf, 'figure.jpg', '-jpg', '-r600'); There is no '...

16 days ago | 0

| accepted

Answered

i am not able to debug because my window is not showing the debug points

Did you try to create the debug points by clicking in the area behind the line numbers? The file has not been saved. So save it...

i am not able to debug because my window is not showing the debug points

Did you try to create the debug points by clicking in the area behind the line numbers? The file has not been saved. So save it...

16 days ago | 0

| accepted

Answered

How to shorten space between space in command window

Avoid the \t for formatting the output if you want to get nice ASCII tables. Prefer to define the width: fprintf('%s%10d%10d%10...

How to shorten space between space in command window

Avoid the \t for formatting the output if you want to get nice ASCII tables. Prefer to define the width: fprintf('%s%10d%10d%10...

16 days ago | 0

Answered

If else Statement in GUI

I guess, that Matlab does exactly what it is expected to do. If h(a)*h(b)>0 is false, Matlab enters the else branch. Although y...

If else Statement in GUI

I guess, that Matlab does exactly what it is expected to do. If h(a)*h(b)>0 is false, Matlab enters the else branch. Although y...

16 days ago | 0

Answered

how to resolve this "not enough input arguments" from the code shown below

objFun=@(mag)summ Now calling objFun calls summ without input arguments. I assume, you mean: objFun = @summ which is a more e...

how to resolve this "not enough input arguments" from the code shown below

objFun=@(mag)summ Now calling objFun calls summ without input arguments. I assume, you mean: objFun = @summ which is a more e...

16 days ago | 0

Answered

Create a for cycle over an array

Do not create a bunch of variables with an index hidden in the names: See TUTORIAL: Why and how to avoid Eval I assume all you ...

Create a for cycle over an array

Do not create a bunch of variables with an index hidden in the names: See TUTORIAL: Why and how to avoid Eval I assume all you ...

16 days ago | 0

| accepted

Answered

why do i get Nan as output?

Use te debugger to determine the first occurrence of a NaN. Type this in the command window: dbstop if naninf Then run the cod...

why do i get Nan as output?

Use te debugger to determine the first occurrence of a NaN. Type this in the command window: dbstop if naninf Then run the cod...

16 days ago | 0

| accepted

Answered

Why is vectorization faster than the parallel computing？

It depends on the problem. Parallelization is not trivial. If you use e.g. 16 cores and write the results in neighboring element...

Why is vectorization faster than the parallel computing？

It depends on the problem. Parallelization is not trivial. If you use e.g. 16 cores and write the results in neighboring element...

16 days ago | 1

| accepted

Answered

How it works : Bilinear interpolation for image resizing

According the the documentation: "the output pixel value is a weighted average of pixels in the nearest 2-by-2 neighborhood" T...

How it works : Bilinear interpolation for image resizing

According the the documentation: "the output pixel value is a weighted average of pixels in the nearest 2-by-2 neighborhood" T...

17 days ago | 0

Answered

Workaround for matrix dimension error

Hints: Avoid repeated code. Prefer: brtn = 255 * get(handles.slider1, 'Value'); instead of writing 255*brtn whenever brtn is ...

Workaround for matrix dimension error

Hints: Avoid repeated code. Prefer: brtn = 255 * get(handles.slider1, 'Value'); instead of writing 255*brtn whenever brtn is ...

17 days ago | 1

| accepted

Answered

how to reduce the size of checkbox

This will not work realiably. Even the OS can change the sizes of specific GUI elements. Use an uitable instead, (see Fabienne's...

how to reduce the size of checkbox

This will not work realiably. Even the OS can change the sizes of specific GUI elements. Use an uitable instead, (see Fabienne's...

17 days ago | 0

Answered

How to clear (not close) all the opened figures?

function clfall FigList = findall(groot, 'Type', 'figure'); for iFig = 1:numel(FigList) try clf(FigList(iFig)); ...

How to clear (not close) all the opened figures?

function clfall FigList = findall(groot, 'Type', 'figure'); for iFig = 1:numel(FigList) try clf(FigList(iFig)); ...

17 days ago | 0

| accepted

Answered

Calling sub-function (local function) from another file on Matlab

This would work: % main.m file: ----------- function out = main(Command, varargin) switch Command case 'sub_function' ...

Calling sub-function (local function) from another file on Matlab

This would work: % main.m file: ----------- function out = main(Command, varargin) switch Command case 'sub_function' ...

17 days ago | 0

Answered

My code is running so long and never gives solution.

To accelerate your code, you can store the results of e.g. D1^5/pi^2 in a variable. This avoids 20 expensive power operations in...

My code is running so long and never gives solution.

To accelerate your code, you can store the results of e.g. D1^5/pi^2 in a variable. This avoids 20 expensive power operations in...

24 days ago | 0

Answered

Index in position 1 exceeds array bounds (must not exceed 1).

We cannot know, what YBUS and IP_DATA is. It is your turn to check, if the error message concerns the variable e, g or f. Do thi...

Index in position 1 exceeds array bounds (must not exceed 1).

We cannot know, what YBUS and IP_DATA is. It is your turn to check, if the error message concerns the variable e, g or f. Do thi...

24 days ago | 0

| accepted

Answered

Saving Tiffs from cell array using imwrite in a loop

for k = 1:numel(ca) imwrite(ca{k}, sprintf('s%d.tiff', k), 'compression', 'none'); end Prefer a naming scheme like s0001....

Saving Tiffs from cell array using imwrite in a loop

for k = 1:numel(ca) imwrite(ca{k}, sprintf('s%d.tiff', k), 'compression', 'none'); end Prefer a naming scheme like s0001....

24 days ago | 0

| accepted

Answered

Merge two colums into one

Assuming that X is your matrix: C = X(:, 2); match = isnan(C); C(match) = X(match, 1);

Merge two colums into one

Assuming that X is your matrix: C = X(:, 2); match = isnan(C); C(match) = X(match, 1);

25 days ago | 0

| accepted

Answered

I want to save multiple images in a folder?

See https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files for k = 1:5 FileName = s...

I want to save multiple images in a folder?

See https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files for k = 1:5 FileName = s...

25 days ago | 0

| accepted

Answered

Error after moving function .m file: 'Previously accessible file "...\z_estimate.m" is now inaccessible'

"saved the file in the top-level MATLAB folder instead of the subfolder "my_functions", which is also on my Matlab path" This s...

Error after moving function .m file: 'Previously accessible file "...\z_estimate.m" is now inaccessible'

"saved the file in the top-level MATLAB folder instead of the subfolder "my_functions", which is also on my Matlab path" This s...

29 days ago | 0

Answered

From Euler Angle to Angle between 2 vectors

There is no mathematical definition of "one angle between 2 3D-bodies". There is more than 1 degeree of freedom. An angle betwee...

From Euler Angle to Angle between 2 vectors

There is no mathematical definition of "one angle between 2 3D-bodies". There is more than 1 degeree of freedom. An angle betwee...

1 month ago | 0

Answered

Error Index exceeds matrix dimensions

After [x ,y] = min(Data(i)); x is a scalar. Then x(i) cannot work for i > 1. By the way, as Adam has said alread, x(i)=x(i) ...

Error Index exceeds matrix dimensions

After [x ,y] = min(Data(i)); x is a scalar. Then x(i) cannot work for i > 1. By the way, as Adam has said alread, x(i)=x(i) ...

1 month ago | 0

Answered

Coding for nested loop problem

for p = 1:10 for q = 1:10 if p ~= q ... end end end Without a for loop: x = rand...

Coding for nested loop problem

for p = 1:10 for q = 1:10 if p ~= q ... end end end Without a for loop: x = rand...

1 month ago | 0

| accepted

Answered

Data filtering(Give a constraint to the length of each index )

There are more efficient ways, but starting with a simple loop is a good apporach: data = [ 1 201; 1 202; 2 301; 2 313; 2 311;...

Data filtering(Give a constraint to the length of each index )

There are more efficient ways, but starting with a simple loop is a good apporach: data = [ 1 201; 1 202; 2 301; 2 313; 2 311;...

1 month ago | 1

| accepted

Answered

Creating 1024 ToggleButtons with almost the same callback

A simplified version of your code: function buttonPress(hObject, EventData, handles) global TData brtn = get(handles.slider1,...

Creating 1024 ToggleButtons with almost the same callback

A simplified version of your code: function buttonPress(hObject, EventData, handles) global TData brtn = get(handles.slider1,...

1 month ago | 0

| accepted