Answered

How to count the number of times I called a function (using the command line)

You could replace counter=0; %Initializing counter by persistent counter if isempty( counter ) counter=0; %Initializin...

How to count the number of times I called a function (using the command line)

You could replace counter=0; %Initializing counter by persistent counter if isempty( counter ) counter=0; %Initializin...

etwa 24 Stunden ago | 0

| accepted

Answered

Is it possible to have an array of function handles?

The short answer is no. However, it's possible to store function handles in a cell array. f = cell(2,1); f{1} = y1prime; f{2...

Is it possible to have an array of function handles?

The short answer is no. However, it's possible to store function handles in a cell array. f = cell(2,1); f{1} = y1prime; f{2...

2 Tage ago | 0

Answered

This statement is not inside any function. (It follows the END that terminates the definition of the function "extract_tiff".)

There are two end at the end of the function. k=k+1; end end Remove one of them

This statement is not inside any function. (It follows the END that terminates the definition of the function "extract_tiff".)

There are two end at the end of the function. k=k+1; end end Remove one of them

3 Tage ago | 0

Answered

Can I control filter command?

Yes, filter() is possible. Try y = filter( 1, [1,1], x );

Can I control filter command?

Yes, filter() is possible. Try y = filter( 1, [1,1], x );

4 Tage ago | 0

| accepted

Answered

Creating a row vector of noisy data.

A naive code noise = 2.0 * randn(1,100); noise = noise .* (2.0./std(noise)); std( noise ) ans = 2 a bit closer...

Creating a row vector of noisy data.

A naive code noise = 2.0 * randn(1,100); noise = noise .* (2.0./std(noise)); std( noise ) ans = 2 a bit closer...

4 Tage ago | 0

Answered

Extracting column from text file

This is a fixed-width text file. The documentation includes a good description on how to read fixed-width text files. See fi...

Extracting column from text file

This is a fixed-width text file. The documentation includes a good description on how to read fixed-width text files. See fi...

6 Tage ago | 0

| accepted

Answered

Sorting numbers according to elements of an array

Without comment: >> [~,ix]=min(abs(SORTING-input)) ix = 1 >> SORTING(ix) ans = 3 >> >> [~,ix]=min(abs(SORTING...

Sorting numbers according to elements of an array

Without comment: >> [~,ix]=min(abs(SORTING-input)) ix = 1 >> SORTING(ix) ans = 3 >> >> [~,ix]=min(abs(SORTING...

6 Tage ago | 1

Answered

how to debugg the error : size input must be integers

"how to debug" Before trying to fix the problem see: Debug a MATLAB Program Next set Pause on Errors and run Section_...

how to debugg the error : size input must be integers

"how to debug" Before trying to fix the problem see: Debug a MATLAB Program Next set Pause on Errors and run Section_...

6 Tage ago | 0

Answered

Does matlab create pointers to objects or create new copies?

See Comparison of Handle and Value Classes

Does matlab create pointers to objects or create new copies?

See Comparison of Handle and Value Classes

6 Tage ago | 1

| accepted

Answered

Namespace management for packages+sub-packages

Yes, that's the way it is. And sprinkle the code with import doesn't really help. Nevertheless, I find packages useful. A bett...

Namespace management for packages+sub-packages

Yes, that's the way it is. And sprinkle the code with import doesn't really help. Nevertheless, I find packages useful. A bett...

6 Tage ago | 0

Answered

Mean command gives wrong answer

Analyze this %% x=[1,2,3,4,5,6,7,8,9,10,11,12]; % x values y=[15,120,2,30,40,150,60,170,80,9,15,1000]; % y values %% idx1 =...

Mean command gives wrong answer

Analyze this %% x=[1,2,3,4,5,6,7,8,9,10,11,12]; % x values y=[15,120,2,30,40,150,60,170,80,9,15,1000]; % y values %% idx1 =...

7 Tage ago | 1

| accepted

Answered

Are enum-comparisons slow in MATLAB?

Indeed, enumerations make slow code. This is an anecdote about a code based on enumeration that proved useless because of poor...

Are enum-comparisons slow in MATLAB?

Indeed, enumerations make slow code. This is an anecdote about a code based on enumeration that proved useless because of poor...

8 Tage ago | 0

Answered

Basic queries Matlab (vectors, indexing, construct matrices in a specific form)

Exercise 1 and 2 "[...] however it confuses me the way the question is written!" Agree; the very same vector has three differe...

Basic queries Matlab (vectors, indexing, construct matrices in a specific form)

Exercise 1 and 2 "[...] however it confuses me the way the question is written!" Agree; the very same vector has three differe...

10 Tage ago | 0

| accepted

Answered

keep element greater than immediate previous element

An alternative %% x = [1 2 3 4 3 2 3 4 6 8 5 5 6 8.5 9 11 12 ]; %% dx = 1; while not( isempty( dx ) ) dx = fin...

keep element greater than immediate previous element

An alternative %% x = [1 2 3 4 3 2 3 4 6 8 5 5 6 8.5 9 11 12 ]; %% dx = 1; while not( isempty( dx ) ) dx = fin...

10 Tage ago | 1

Answered

How to reduce computation time

On R2018b and a new vanilla PC I found a significant decrease in computation time by replacing quad2d() by integral2() (with the...

How to reduce computation time

On R2018b and a new vanilla PC I found a significant decrease in computation time by replacing quad2d() by integral2() (with the...

10 Tage ago | 1

Answered

How can I write a variable which datatype is a string in netcdf file

Most likely, the space you specified for the variable calibration_procedure in the nc-file, i.e. 'Dimensions',{'hydrophone_cou...

How can I write a variable which datatype is a string in netcdf file

Most likely, the space you specified for the variable calibration_procedure in the nc-file, i.e. 'Dimensions',{'hydrophone_cou...

11 Tage ago | 0

| accepted

Answered

constructing a difficult large matrix

Here are three functions, two of which are based on the answer of David Goodmanson. I think all of them are fast enough. However...

constructing a difficult large matrix

Here are three functions, two of which are based on the answer of David Goodmanson. I think all of them are fast enough. However...

11 Tage ago | 1

Answered

Randomly convert exact number of 1 to 0 in binary matrix

Try %% x = [ 0 1 0 1 0 1 1 1 1]; %% ix_one = find( x == 1 ); ix_set_zero = randi( numel(ix_one), 1,2 ); x( ...

Randomly convert exact number of 1 to 0 in binary matrix

Try %% x = [ 0 1 0 1 0 1 1 1 1]; %% ix_one = find( x == 1 ); ix_set_zero = randi( numel(ix_one), 1,2 ); x( ...

12 Tage ago | 0

| accepted

Answered

number permutate without permutation

Steps to find a substitute for perms without perms Lookup perms in the documenttion, perms, All possible permutations See "Se...

number permutate without permutation

Steps to find a substitute for perms without perms Lookup perms in the documenttion, perms, All possible permutations See "Se...

13 Tage ago | 0

Answered

is 2GB RAM ok for MATLAB 2020 ?

Yes, you don't need to install Polyspace, but plain Matlab requires a minimum of 4GB. See System Requirements for MATLAB R2020a

is 2GB RAM ok for MATLAB 2020 ?

Yes, you don't need to install Polyspace, but plain Matlab requires a minimum of 4GB. See System Requirements for MATLAB R2020a

14 Tage ago | 0

| accepted

Answered

Storing data from a loop

Pre-allocate Y1 and Y2 Assign to elements of Y1 and Y2 Do not change the loop counter, ii, in the loop The documentation say...

Storing data from a loop

Pre-allocate Y1 and Y2 Assign to elements of Y1 and Y2 Do not change the loop counter, ii, in the loop The documentation say...

14 Tage ago | 0

Answered

I am having problems with my homework:Write a function called valid_date that takes three positive integer scalar inputs year, month, day....

Replace (rem(year,4)==0 && rem(year,100)~=0) || (rem(year,400)==0 && rem(year,100)~=0) by (rem(year,4)==0 && rem(year,100)~=...

I am having problems with my homework:Write a function called valid_date that takes three positive integer scalar inputs year, month, day....

Replace (rem(year,4)==0 && rem(year,100)~=0) || (rem(year,400)==0 && rem(year,100)~=0) by (rem(year,4)==0 && rem(year,100)~=...

15 Tage ago | 0

Answered

cellfun vs. varfun applied to column of table

This works, but may contain more code than you hoped for. %% T = table({'147956, 154414'; '1, 7439'; '93053, 101815'; '50151, ...

cellfun vs. varfun applied to column of table

This works, but may contain more code than you hoped for. %% T = table({'147956, 154414'; '1, 7439'; '93053, 101815'; '50151, ...

15 Tage ago | 1

Answered

Continuing an input function onto another line

The documentation says; The start and end quotation marks for a character vector must appear on the same line. For example, thi...

Continuing an input function onto another line

The documentation says; The start and end quotation marks for a character vector must appear on the same line. For example, thi...

17 Tage ago | 0

Answered

export codes written in editor into word

See Bring along your syntax highlighted code and M2HTML: Documentation System for MATLAB in HTML

export codes written in editor into word

See Bring along your syntax highlighted code and M2HTML: Documentation System for MATLAB in HTML

18 Tage ago | 1

| accepted

Answered

Transaction Data in HTML file

This is a start %% sad = dir( 'd:\m\cssm\transData*.txt' ); len = length( sad ); out = cell( len, 2 ); for jj = 1 : len ...

Transaction Data in HTML file

This is a start %% sad = dir( 'd:\m\cssm\transData*.txt' ); len = length( sad ); out = cell( len, 2 ); for jj = 1 : len ...

20 Tage ago | 0

| accepted

Answered

Textscan with '@' as delimiter

I've reproduced your result on R2018b. The result is according to the textscan documentation - I think. out1 is a cell array of...

Textscan with '@' as delimiter

I've reproduced your result on R2018b. The result is according to the textscan documentation - I think. out1 is a cell array of...

22 Tage ago | 0

| accepted

Answered

Converting txt file into title and array?

Try this %% fid = fopen( 'cssm.txt', 'rt' ); xL = fgetl( fid ); % read the first line data = fscanf( fid, '...

Converting txt file into title and array?

Try this %% fid = fopen( 'cssm.txt', 'rt' ); xL = fgetl( fid ); % read the first line data = fscanf( fid, '...

22 Tage ago | 0

| accepted

Answered

Updating a Property in an Array of Objects

The documentation doesn't tell that a statement like [WorkOrder(1,:,1).nid] = listData.nid(:,1); isn't possible. You are not t...

Updating a Property in an Array of Objects

The documentation doesn't tell that a statement like [WorkOrder(1,:,1).nid] = listData.nid(:,1); isn't possible. You are not t...

22 Tage ago | 0

| accepted