12.545 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

convert lower case to upper and upper to lower

You can use the function isstrprop with the category 'lower' and 'upper' to identify the specific characters. Then use the comma...

convert lower case to upper and upper to lower

You can use the function isstrprop with the category 'lower' and 'upper' to identify the specific characters. Then use the comma...

alrededor de 6 horas ago | 0

Answered

Return vectors from for loop as columns in matrix

Start with cleaning up the code. The lines Dplus; and Dminus; do nothing, so they are wasting time only and confuse the readers...

Return vectors from for loop as columns in matrix

Start with cleaning up the code. The lines Dplus; and Dminus; do nothing, so they are wasting time only and confuse the readers...

alrededor de 6 horas ago | 1

Answered

Function run(scriptname) doesn't work.

Store the M-files in a folder, in which you have full access. C:\Users\ is a bad idea. Create a folder somewhere else, e.g. insi...

Function run(scriptname) doesn't work.

Store the M-files in a folder, in which you have full access. C:\Users\ is a bad idea. Create a folder somewhere else, e.g. insi...

alrededor de 9 horas ago | 0

Answered

Subtracting Vector from a Matrix

Matlab can subtract vectors from matrices automatically since R2016b - so called "auto expanding". Do you use an older version? ...

Subtracting Vector from a Matrix

Matlab can subtract vectors from matrices automatically since R2016b - so called "auto expanding". Do you use an older version? ...

alrededor de 9 horas ago | 0

| accepted

Answered

Include global variable declaration infunctions

Global variables are a shot in your knee in every case. Hiding them in scripts, which are called dynamically, impedes the debugg...

Include global variable declaration infunctions

Global variables are a shot in your knee in every case. Hiding them in scripts, which are called dynamically, impedes the debugg...

alrededor de 11 horas ago | 0

Answered

deleted old version of Matlab (R2017b) keeps getting back

See https://nektony.com/how-to/uninstall-matlab-mac According to https://www.mathworks.com/help/install/ug/uninstall-mathworks-...

deleted old version of Matlab (R2017b) keeps getting back

See https://nektony.com/how-to/uninstall-matlab-mac According to https://www.mathworks.com/help/install/ug/uninstall-mathworks-...

alrededor de 11 horas ago | 1

| accepted

Answered

I found this bellow code in internet. While I run the code I noticed following errors.

This is a strange and inefficient code. Replace e.g. for i=1:len for j= 2:2 text_names(i,j)=txt(i,j); end ...

I found this bellow code in internet. While I run the code I noticed following errors.

This is a strange and inefficient code. Replace e.g. for i=1:len for j= 2:2 text_names(i,j)=txt(i,j); end ...

alrededor de 12 horas ago | 0

Answered

Vectorise or Parallel Computing

This loop cannot be parallelized. If flux_edge is a vector and not a matrix, accumarray would solve the problem efficiently. Try...

Vectorise or Parallel Computing

This loop cannot be parallelized. If flux_edge is a vector and not a matrix, accumarray would solve the problem efficiently. Try...

alrededor de 13 horas ago | 0

Answered

How do I return an extra parameter using Matlab's ODE solvers?

If the problems mentioned in my comment are fixed, the solution is easy: Run the integration at first. Then provide the calcualt...

How do I return an extra parameter using Matlab's ODE solvers?

If the problems mentioned in my comment are fixed, the solution is easy: Run the integration at first. Then provide the calcualt...

1 día ago | 0

Answered

Assign column index to output value

An easier way to create the submatrix: submatrix = M(i:end, :); The any() operates along the first non-singelton dimension. Fo...

Assign column index to output value

An easier way to create the submatrix: submatrix = M(i:end, :); The any() operates along the first non-singelton dimension. Fo...

1 día ago | 0

Answered

Index exceeds the number of array elements (4)

You stop Matlab at the error already by dbstop if error. Then use the debugger to check the sizes of the arrays: size(zplot) s...

Index exceeds the number of array elements (4)

You stop Matlab at the error already by dbstop if error. Then use the debugger to check the sizes of the arrays: size(zplot) s...

1 día ago | 0

| accepted

Answered

Problem with Matrix indexing using vector

This is a job for sub2ind: a = blkdiag(ones(3),ones(3)); [r,c] = find(a); b = zeros(size(a)); index = su...

Problem with Matrix indexing using vector

This is a job for sub2ind: a = blkdiag(ones(3),ones(3)); [r,c] = find(a); b = zeros(size(a)); index = su...

1 día ago | 0

| accepted

Answered

MEX passing Integer - wrong results

This sounds magic. Whenever magic things appear in discussions in the forum, or at programming in general, it is a secure signal...

MEX passing Integer - wrong results

This sounds magic. Whenever magic things appear in discussions in the forum, or at programming in general, it is a secure signal...

9 días ago | 2

Answered

how to avoid for loop

A ,ore efficient version of the loop: nb = numel(b) - 1; counts = zeros(1, nb); % Pre-allocation!!! for i = 1:nb co...

how to avoid for loop

A ,ore efficient version of the loop: nb = numel(b) - 1; counts = zeros(1, nb); % Pre-allocation!!! for i = 1:nb co...

15 días ago | 0

| accepted

Answered

Using matlab to find vectors that are orthogonal to another vector.

Do you mean 2D vectors? v = rand(1, 2) % Any test vector vp = [-v(2), v(1)] dot(v, vp) % Orthogonal means: dot pro...

Using matlab to find vectors that are orthogonal to another vector.

Do you mean 2D vectors? v = rand(1, 2) % Any test vector vp = [-v(2), v(1)] dot(v, vp) % Orthogonal means: dot pro...

15 días ago | 0

| accepted

Answered

11221 212211 212 12 1

Please post an exact copy of the error message in the forum. A rough paraphrasing will hide important details. Thanks. I assume...

11221 212211 212 12 1

Please post an exact copy of the error message in the forum. A rough paraphrasing will hide important details. Thanks. I assume...

15 días ago | 0

Answered

faster way to add many large matrix in matlab

The main time is spent in rand() in your example. With using ones() instead, the runtime goes from 0.71 sec to 0.25 sec on my ma...

faster way to add many large matrix in matlab

The main time is spent in rand() in your example. With using ones() instead, the runtime goes from 0.71 sec to 0.25 sec on my ma...

17 días ago | 0

| accepted

Answered

Convert CurrentPoint to X and Y Value.

I guess that you do not want the coordinates relative to the figure, but relative to the data in an AXES object. Then: CP = get...

Convert CurrentPoint to X and Y Value.

I guess that you do not want the coordinates relative to the figure, but relative to the data in an AXES object. Then: CP = get...

17 días ago | 3

Answered

P files cannot be analyzed to find their dependencies. Please add P file dependencies manually

I'd start with a web search: Ask your favorite search engine for "Matlab get dependencies of P file". You will find e.g.: https...

P files cannot be analyzed to find their dependencies. Please add P file dependencies manually

I'd start with a web search: Ask your favorite search engine for "Matlab get dependencies of P file". You will find e.g.: https...

alrededor de 2 meses ago | 2

| accepted

Answered

Is it possible to concatenate structures with the same fields in to one super structure?

Or with a loop: function S = CatStructFields(S, T, dim) fields = fieldnames(S); for k = 1:numel(fields) aField = field...

Is it possible to concatenate structures with the same fields in to one super structure?

Or with a loop: function S = CatStructFields(S, T, dim) fields = fieldnames(S); for k = 1:numel(fields) aField = field...

alrededor de 2 meses ago | 3

Answered

Query in applying If command

if (abs(G(j)-O(:))<1) The if command needs a scalar condition. Therefore Matlab inserts an all() to evaluate the vector G(j)-O(...

Query in applying If command

if (abs(G(j)-O(:))<1) The if command needs a scalar condition. Therefore Matlab inserts an all() to evaluate the vector G(j)-O(...

alrededor de 2 meses ago | 0

Answered

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

The variable tab has the dimensions 5 x 10. You try to access the indices [100, 5, 10]. This cannot work. I guess, you want to r...

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

The variable tab has the dimensions 5 x 10. You try to access the indices [100, 5, 10]. This cannot work. I guess, you want to r...

alrededor de 2 meses ago | 0

Answered

How to Assign vectors to each dynamic variable name?

Don't do this. See: TUTORIAL: How and why to avoid Eval Hiding an index in the name of variables is a bad idea. Use arrays ins...

How to Assign vectors to each dynamic variable name?

Don't do this. See: TUTORIAL: How and why to avoid Eval Hiding an index in the name of variables is a bad idea. Use arrays ins...

alrededor de 2 meses ago | 3

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) ...

2 meses 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...

2 meses 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...

2 meses 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...

3 meses 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?

3 meses 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...

3 meses 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 '...

3 meses ago | 0

| accepted