Answered

Trying to see if a variable is an integer or not

Try this %% x=2.5; answer = ( x == floor(x) )

Trying to see if a variable is an integer or not

Try this %% x=2.5; answer = ( x == floor(x) )

3 mois ago | 0

| accepted

Answered

Not enough input arguments.

You need to call the function, Lorenz, with two input arguments: t and x. E.g. %% x = (1:6); t = nan; xprime = Lorenz( t, x...

Not enough input arguments.

You need to call the function, Lorenz, with two input arguments: t and x. E.g. %% x = (1:6); t = nan; xprime = Lorenz( t, x...

3 mois ago | 0

| accepted

Answered

Help indexing: How to index at the interfaces of cells and not the cells

Index in position 2 exceeds array bounds U(:,j+2) is most likely the problem. I assume that the size of U is NEQxN. The max...

Help indexing: How to index at the interfaces of cells and not the cells

Index in position 2 exceeds array bounds U(:,j+2) is most likely the problem. I assume that the size of U is NEQxN. The max...

3 mois ago | 1

| accepted

Answered

Problems in reading large matrix with large empty cells

This script reads your sample file %% opts = fixedWidthImportOptions('NumVariables',36,'DataLines',4,... 'VariableNames',{'IN...

Problems in reading large matrix with large empty cells

This script reads your sample file %% opts = fixedWidthImportOptions('NumVariables',36,'DataLines',4,... 'VariableNames',{'IN...

3 mois ago | 0

| accepted

Answered

out of memory error for large data

See How to export complex-valued matrix to HDF file

out of memory error for large data

See How to export complex-valued matrix to HDF file

3 mois ago | 0

Answered

Error: Not enough input arguments

Accourding to the definition function [ U_RK ] = RK4( U_T, Res, dx, dt, k, N ) requires six input values. Your call of the fun...

Error: Not enough input arguments

Accourding to the definition function [ U_RK ] = RK4( U_T, Res, dx, dt, k, N ) requires six input values. Your call of the fun...

3 mois ago | 0

| accepted

Answered

Best Matlab Editor replacement?

I have not always been loyal to the Matlab editor (ME) Long time ago I used the full version of the ED editor that comes (or di...

Best Matlab Editor replacement?

I have not always been loyal to the Matlab editor (ME) Long time ago I used the full version of the ED editor that comes (or di...

3 mois ago | 0

| accepted

Answered

Getting error while deleting every row of the matrix M that contains the variable x

The trick is to iterate in reverse order, i.e a:-1:1 instead of 1:a. Try this %% M = magic(5); x = 13; N = Delete_var(x,M) ...

Getting error while deleting every row of the matrix M that contains the variable x

The trick is to iterate in reverse order, i.e a:-1:1 instead of 1:a. Try this %% M = magic(5); x = 13; N = Delete_var(x,M) ...

3 mois ago | 0

| accepted

Answered

How to remove both leading and trailing zeros from a binary string?

Is this what you look for? %% A=["00000001111";"00000110010";"10111011100";"00001000110";"11111010000";"00000001010"]; %% B ...

How to remove both leading and trailing zeros from a binary string?

Is this what you look for? %% A=["00000001111";"00000110010";"10111011100";"00001000110";"11111010000";"00000001010"]; %% B ...

3 mois ago | 0

| accepted

Answered

MATLAB Answers Wish-list #5 (and bug reports)

I wish Answers would automatically reject comments like "I did that but it didnt work"

MATLAB Answers Wish-list #5 (and bug reports)

I wish Answers would automatically reject comments like "I did that but it didnt work"

3 mois ago | 3

Answered

I want to read a bunch of files inside a loop function in MATLAB, but when I try the following code:

What do you suppose that the following statement will do? j = (i * 2000000); Replace A = dlmread('gr_at_0.l_%d', j); by A =...

I want to read a bunch of files inside a loop function in MATLAB, but when I try the following code:

What do you suppose that the following statement will do? j = (i * 2000000); Replace A = dlmread('gr_at_0.l_%d', j); by A =...

3 mois ago | 0

Answered

unable to make directory in specified folder

"it won't recognize this slef-made folder" Did you add it to Matlab's search path? On my system, R2018b,Win10, your script wo...

unable to make directory in specified folder

"it won't recognize this slef-made folder" Did you add it to Matlab's search path? On my system, R2018b,Win10, your script wo...

3 mois ago | 1

Answered

How to import a function from another package

Your folder, Model, is not a Matlab package. Package folders always begin with the + character. See Packages Create Namespaces....

How to import a function from another package

Your folder, Model, is not a Matlab package. Package folders always begin with the + character. See Packages Create Namespaces....

3 mois ago | 0

| accepted

Answered

Split a string into 4 character groups?

"Split a string into 4 character groups?", "split this output string into groups of characters" and "I want to group at this sta...

Split a string into 4 character groups?

"Split a string into 4 character groups?", "split this output string into groups of characters" and "I want to group at this sta...

3 mois ago | 0

| accepted

Answered

Please, help with Matlab code

Your function works just fine longestword("Heat","Lakers","Warriors") longestword("cent","centennial","century") longestword(...

Please, help with Matlab code

Your function works just fine longestword("Heat","Lakers","Warriors") longestword("cent","centennial","century") longestword(...

3 mois ago | 1

Answered

How to read in large text file with special delimiters?

"Is there any way to specify your own row and column delimiters to be able to read in this data?" No, I don't think so. How la...

How to read in large text file with special delimiters?

"Is there any way to specify your own row and column delimiters to be able to read in this data?" No, I don't think so. How la...

3 mois ago | 1

| accepted

Answered

Nested elseif statement syntax

There is no else block in the outer if-elseif-else-end. This code will display something only for inputs(1)==0 and for inputs(1)...

Nested elseif statement syntax

There is no else block in the outer if-elseif-else-end. This code will display something only for inputs(1)==0 and for inputs(1)...

3 mois ago | 0

Answered

how to simulate different investments

Based on your question, I've made a small object oriented demo. You don't prescribe how many shares an investor will trade in...

how to simulate different investments

Based on your question, I've made a small object oriented demo. You don't prescribe how many shares an investor will trade in...

3 mois ago | 0

Answered

can anyone help me prepare the code

Problems with your script The long lines make the code hard to read. Numerous statement separators are missing I added line ...

can anyone help me prepare the code

Problems with your script The long lines make the code hard to read. Numerous statement separators are missing I added line ...

3 mois ago | 0

Answered

is it possible to create array of strings or char from struct of cell arrays

There are character arrays (See Text and Characters) A(1).name='one'; A(1).val=1; A(2).name='two'; A(2).val=2; {A.name} [A.na...

is it possible to create array of strings or char from struct of cell arrays

There are character arrays (See Text and Characters) A(1).name='one'; A(1).val=1; A(2).name='two'; A(2).val=2; {A.name} [A.na...

3 mois ago | 0

| accepted

Answered

Changing elements in a MxN matrix

Does this help? %% matrix = magic(10); matrix = triu( matrix,-4 ); matrix = tril( matrix, 4 ) %% This is better, it only ...

Changing elements in a MxN matrix

Does this help? %% matrix = magic(10); matrix = triu( matrix,-4 ); matrix = tril( matrix, 4 ) %% This is better, it only ...

3 mois ago | 0

| accepted

Answered

Extracting values out of a cell array with tables

This script puts all the numerical data into a row vector (column-wise). You didn't say anything about order. %% load('CA.mat'...

Extracting values out of a cell array with tables

This script puts all the numerical data into a row vector (column-wise). You didn't say anything about order. %% load('CA.mat'...

3 mois ago | 1

| accepted

Answered

Issues with plotting/best method

I added 'd' to all your plot-commands plot(b0(1,1), z(1,1), 'd' ) keyboard hold on plot(t0(1,1), z(2,1), 'd' ) plot(b1(1,1)...

Issues with plotting/best method

I added 'd' to all your plot-commands plot(b0(1,1), z(1,1), 'd' ) keyboard hold on plot(t0(1,1), z(2,1), 'd' ) plot(b1(1,1)...

3 mois ago | 0

Answered

Organizing images in datastore and accessing them with parameters

The statement imds = imageDatastore(location) creates an instance of the class, ImageDatastore. My first idea was to subclas...

Organizing images in datastore and accessing them with parameters

The statement imds = imageDatastore(location) creates an instance of the class, ImageDatastore. My first idea was to subclas...

4 mois ago | 0

Answered

Brace indexing is not supported for variables of this type.

"How do I call the sort_nat function to sort folders?" Examples Find sorted file names >> sad = dir('d:\m\cssm\*.txt'); >> ...

Brace indexing is not supported for variables of this type.

"How do I call the sort_nat function to sort folders?" Examples Find sorted file names >> sad = dir('d:\m\cssm\*.txt'); >> ...

4 mois ago | 0

Answered

understanding "<" operator line

Consider the two lines midCirc = X.^2+Y.^2 < (1/n)^2; NmidCirc = not(midCirc); The first line assigns a logical value (true/f...

understanding "<" operator line

Consider the two lines midCirc = X.^2+Y.^2 < (1/n)^2; NmidCirc = not(midCirc); The first line assigns a logical value (true/f...

4 mois ago | 0

Answered

Searching for a matched string within nested cell and delivering the index

Assume there is ONE cell contaning 'TOTAL' Try %% ix = find( cellfun( @(cac) strcmp(cac{1},'TOTAL'), values ) ); num = value...

Searching for a matched string within nested cell and delivering the index

Assume there is ONE cell contaning 'TOTAL' Try %% ix = find( cellfun( @(cac) strcmp(cac{1},'TOTAL'), values ) ); num = value...

4 mois ago | 0

| accepted

Answered

Take average of multiple matrices

Try this %% load('data.mat') num = cat( 3, phi_BFD_v_sum{:} ); avg = mean( num, 3 ); peek >> avg avg = 0 ...

Take average of multiple matrices

Try this %% load('data.mat') num = cat( 3, phi_BFD_v_sum{:} ); avg = mean( num, 3 ); peek >> avg avg = 0 ...

4 mois ago | 1

Answered

Pre-allocating cell containers

"I have pre-allocated memory". After pre-allocating memory for a variable you must not change its size. If you do, the effect o...

Pre-allocating cell containers

"I have pre-allocated memory". After pre-allocating memory for a variable you must not change its size. If you do, the effect o...

4 mois ago | 0

Answered

how to save the outputs obtained by a for loop repeated n times

tot is overwritten in each iteration of the for-loop Replace tot = (Tin{idx(:,i),i+1:i+3}); by tot(:,i) = (Tin{idx(:,i),i+...

how to save the outputs obtained by a for loop repeated n times

tot is overwritten in each iteration of the for-loop Replace tot = (Tin{idx(:,i),i+1:i+3}); by tot(:,i) = (Tin{idx(:,i),i+...

4 mois ago | 0

| accepted