Answered

convert matrix data to cell array data

Try this >> num2cell( magic(5), 1 ) ans = 1×5 cell array Columns 1 through 4 {5×1 double} {5×1 double} {5×1 d...

convert matrix data to cell array data

Try this >> num2cell( magic(5), 1 ) ans = 1×5 cell array Columns 1 through 4 {5×1 double} {5×1 double} {5×1 d...

3 månader ago | 0

| accepted

Answered

how do I store an array of functions?

An error message tells me Nonscalar arrays of function handles are not allowed; use cell arrays instead. Is this what are loo...

how do I store an array of functions?

An error message tells me Nonscalar arrays of function handles are not allowed; use cell arrays instead. Is this what are loo...

3 månader ago | 0

Answered

How to get drive name?

On Windows this function works with my local drives >> DriveName( 'C' ) ans = 'OSDisk' >> DriveName( 'D' ) ans = '...

How to get drive name?

On Windows this function works with my local drives >> DriveName( 'C' ) ans = 'OSDisk' >> DriveName( 'D' ) ans = '...

3 månader ago | 1

| accepted

Answered

Getting error about index in for loop

Three problems: replace 0:size(dataN) by 1:size(dataN,2). Matlab's indexing is one-based. avg = mean(val); overwrites avg in e...

Getting error about index in for loop

Three problems: replace 0:size(dataN) by 1:size(dataN,2). Matlab's indexing is one-based. avg = mean(val); overwrites avg in e...

3 månader ago | 0

Answered

Optimizing code run time

Try to replace M = load(fullfile(path,'M.mat')); by persistent M if isempty(M) M = load(fullfile(path,'M.mat')); end ...

Optimizing code run time

Try to replace M = load(fullfile(path,'M.mat')); by persistent M if isempty(M) M = load(fullfile(path,'M.mat')); end ...

3 månader ago | 0

| accepted

Answered

How to Keep Nested For Loop Indexes From Equaling Each Other

for ii=1:50 for jj=1:50 if not(jj==ii) code end end end See i, Imaginary unit

How to Keep Nested For Loop Indexes From Equaling Each Other

for ii=1:50 for jj=1:50 if not(jj==ii) code end end end See i, Imaginary unit

3 månader ago | 0

Answered

How can i store data in a cell array with single row and few number of columns?

Pre-allocate ACC before the for-loop ACC = cell( 1, 20 ); replace all ACC{a,1} by ACC{a}

How can i store data in a cell array with single row and few number of columns?

Pre-allocate ACC before the for-loop ACC = cell( 1, 20 ); replace all ACC{a,1} by ACC{a}

3 månader ago | 0

Answered

New class object every iteration

In most cases it's better to create an array of objects. The documentations provides one way. See Construct Object Arrays. Wha...

New class object every iteration

In most cases it's better to create an array of objects. The documentations provides one way. See Construct Object Arrays. Wha...

3 månader ago | 0

| accepted

Answered

My home tab and command line are missing in MATLAB 2019b

Your screen shows an undocked Matlab Editor - I think. Notice the icon in the upper left corner here is a screen clip from an...

My home tab and command line are missing in MATLAB 2019b

Your screen shows an undocked Matlab Editor - I think. Notice the icon in the upper left corner here is a screen clip from an...

3 månader ago | 0

| accepted

Answered

How to access a row elements of a field of a structure

Assumption: "three rows and 10 columns" refers to a 3x10 double matrix Try %% A.f1 = randi( [0,9], 3, 8 ); % sample dat...

How to access a row elements of a field of a structure

Assumption: "three rows and 10 columns" refers to a 3x10 double matrix Try %% A.f1 = randi( [0,9], 3, 8 ); % sample dat...

3 månader ago | 0

Answered

How can I define a class constant based on an abstract constant?

Doesn't this meet your requirements? The property, data, doesn't need Abstract=true and it would force you to define data in al...

How can I define a class constant based on an abstract constant?

Doesn't this meet your requirements? The property, data, doesn't need Abstract=true and it would force you to define data in al...

3 månader ago | 0

| accepted

Answered

BUG in nargin < 3

The example works as expected for me. It throws an error because no value is assigned to y >> y = myfunction( 1, 2, true ) Out...

BUG in nargin < 3

The example works as expected for me. It throws an error because no value is assigned to y >> y = myfunction( 1, 2, true ) Out...

3 månader ago | 1

| accepted

Answered

Column indexing with condition

Try this >> isn = any( A<0, 1 ); >> B(:,isn) = -B(:,isn) B = 1 -2 -3 4 -5 -6 7 -8 -9 and...

Column indexing with condition

Try this >> isn = any( A<0, 1 ); >> B(:,isn) = -B(:,isn) B = 1 -2 -3 4 -5 -6 7 -8 -9 and...

3 månader ago | 0

| accepted

Answered

How can I count the number of times a specific value appears within a range in a 1D vector?

If x is a vector of whole numbers sum( double( x(151:end)==1 ) ) else sum( double( abs(x(151:end)-1) < small_number ) )

How can I count the number of times a specific value appears within a range in a 1D vector?

If x is a vector of whole numbers sum( double( x(151:end)==1 ) ) else sum( double( abs(x(151:end)-1) < small_number ) )

3 månader ago | 0

Answered

Why can't I convert from datenum to datetime?

The datetime statement is ok. >> d_times=datetime( now, 'ConvertFrom', 'datenum'); >> d_times d_times = datetime 27-A...

Why can't I convert from datenum to datetime?

The datetime statement is ok. >> d_times=datetime( now, 'ConvertFrom', 'datenum'); >> d_times d_times = datetime 27-A...

4 månader ago | 0

Answered

ERROR while running value function iteration code: Index in position 2 exceeds array bounds (must not exceed 2).

Before trying to fix the problems see: Debug a MATLAB Program Then start by reading the code carefully. The first thing that ca...

ERROR while running value function iteration code: Index in position 2 exceeds array bounds (must not exceed 2).

Before trying to fix the problems see: Debug a MATLAB Program Then start by reading the code carefully. The first thing that ca...

4 månader ago | 0

Answered

Inputing textfile data as meaningful variables

Matlab provides several different functions to read text files. (I'm used to textscan.) "cell array of all values in that first...

Inputing textfile data as meaningful variables

Matlab provides several different functions to read text files. (I'm used to textscan.) "cell array of all values in that first...

4 månader ago | 1

| accepted

Answered

How to load Excel .xlsx and .mat files into Matlab?

The function, load(), cannot read excel-files. "when I use "load FileName" I get an error" FileName is that the name of a mat-...

How to load Excel .xlsx and .mat files into Matlab?

The function, load(), cannot read excel-files. "when I use "load FileName" I get an error" FileName is that the name of a mat-...

4 månader ago | 0

| accepted

Answered

how to call a nested function from a method

"how nested functions in Methods behave" the same way as in functions "call the "child" function from a different script" the...

how to call a nested function from a method

"how nested functions in Methods behave" the same way as in functions "call the "child" function from a different script" the...

4 månader ago | 0

| accepted

Answered

Function that calls functions

Caveat: I'm guessing. Replace nfin=2*(Integral_Numerical_1_potential(R(1:4),3,a,b)+Integral_Numerical_2(R(4:end),M-3,a,b))/(1...

Function that calls functions

Caveat: I'm guessing. Replace nfin=2*(Integral_Numerical_1_potential(R(1:4),3,a,b)+Integral_Numerical_2(R(4:end),M-3,a,b))/(1...

4 månader ago | 0

| accepted

Answered

Using reshape to manipulate a large matrix

"I dont know how to scale down the matrix by any factor other than 2" What's wrong with your code? I think your code works jus...

Using reshape to manipulate a large matrix

"I dont know how to scale down the matrix by any factor other than 2" What's wrong with your code? I think your code works jus...

4 månader ago | 0

| accepted

Answered

How do you continue a string on the next line in Psychtoolbox?

The strings, 'center', 'center', are they really intended to be part of the second input argument of DrawFormattedText() ? I g...

How do you continue a string on the next line in Psychtoolbox?

The strings, 'center', 'center', are they really intended to be part of the second input argument of DrawFormattedText() ? I g...

4 månader ago | 0

| accepted

Answered

Invalid default value for property error in class properties

In the properties block one must refer to a as MyClass.a when Constant. >> mc = MyClass mc = MyClass with properties: ...

Invalid default value for property error in class properties

In the properties block one must refer to a as MyClass.a when Constant. >> mc = MyClass mc = MyClass with properties: ...

4 månader ago | 0

| accepted

Answered

NetCDF File Assign Variable Loop from Array

Partial answer. Replace ? = ncread('../data/isff_20070403_20.nc',fNameu); by assign( txt, ncread('../data/isff_20070403_20.nc...

NetCDF File Assign Variable Loop from Array

Partial answer. Replace ? = ncread('../data/isff_20070403_20.nc',fNameu); by assign( txt, ncread('../data/isff_20070403_20.nc...

4 månader ago | 0

| accepted

Answered

How do I convert a string to date time?

I found this example in the documentation of datetime Specify the current date and time in the time zone represented by Seoul, ...

How do I convert a string to date time?

I found this example in the documentation of datetime Specify the current date and time in the time zone represented by Seoul, ...

4 månader ago | 0

Answered

How can I extract a single value from every 86 lines of a long text file?

Try this %% Read all lines as text fid = fopen( 'fort18000.txt' ); cac = textscan( fid, '%s', 'Delimiter','\n' ); [~] = fclo...

How can I extract a single value from every 86 lines of a long text file?

Try this %% Read all lines as text fid = fopen( 'fort18000.txt' ); cac = textscan( fid, '%s', 'Delimiter','\n' ); [~] = fclo...

4 månader ago | 0

| accepted

Answered

how to extract a specific data from struct formatted dataset

Try this %% z = load('B0005.mat'); len = length(z.B0005.cycle); a = zeros( len, 1 ); for ii = 1:len if strcmp( z.B00...

how to extract a specific data from struct formatted dataset

Try this %% z = load('B0005.mat'); len = length(z.B0005.cycle); a = zeros( len, 1 ); for ii = 1:len if strcmp( z.B00...

4 månader ago | 0

| accepted

Answered

Matlab does not save the variable in each loop

you need to pre-allocate Tout, something like N = appropriate value Tout = cell(1,N); before assigning values

Matlab does not save the variable in each loop

you need to pre-allocate Tout, something like N = appropriate value Tout = cell(1,N); before assigning values

4 månader ago | 1

| accepted

Answered

This code is not working, it return an issue stating with vector length, please help out

The size of the variables, x2 and w, must be the same. They are not. >> whos x1 v x2 w Name Size Bytes Cla...

This code is not working, it return an issue stating with vector length, please help out

The size of the variables, x2 and w, must be the same. They are not. >> whos x1 v x2 w Name Size Bytes Cla...

4 månader ago | 0

Answered

How can I find x values given a FOR command?

Replace find (x) = 0:5:55 by x(1:round(5/dt):end,:) This should work since 5/dt is a whole number. round takes care of a po...

How can I find x values given a FOR command?

Replace find (x) = 0:5:55 by x(1:round(5/dt):end,:) This should work since 5/dt is a whole number. round takes care of a po...

4 månader ago | 1

| accepted