Answered

animate multiple lines one by one

You could do something like this % Make some example data U1 = rand(101,101) x = linspace(1,10,101); % plot every 20th col...

animate multiple lines one by one

You could do something like this % Make some example data U1 = rand(101,101) x = linspace(1,10,101); % plot every 20th col...

2 months ago | 1

| accepted

Answered

Multiple initial points in fmincon optimization

As @Alan Weiss points out it seems that you are misunderstanding how MATLAB interprets the 2 by 3 array you are inputting as x0....

Multiple initial points in fmincon optimization

As @Alan Weiss points out it seems that you are misunderstanding how MATLAB interprets the 2 by 3 array you are inputting as x0....

2 months ago | 0

Answered

using lsqnonlin with constraints

From my understanding lsqnonlin only allows for bound constraints on the components of x. For more general problems you will hav...

using lsqnonlin with constraints

From my understanding lsqnonlin only allows for bound constraints on the components of x. For more general problems you will hav...

2 months ago | 0

Answered

How to use ODE45 for a coupled system of differential equations at a specific time point

So, expanding on @Davide Masiello comment, if all you want is the final solution at t = 2.2s you could wrap your call to ode45 u...

How to use ODE45 for a coupled system of differential equations at a specific time point

So, expanding on @Davide Masiello comment, if all you want is the final solution at t = 2.2s you could wrap your call to ode45 u...

2 months ago | 0

| accepted

Answered

How can I remove empty cells from struct data?

You can adapt @Stephen23's approach given in https://www.mathworks.com/matlabcentral/answers/613956-how-to-check-if-a-element-of...

How can I remove empty cells from struct data?

You can adapt @Stephen23's approach given in https://www.mathworks.com/matlabcentral/answers/613956-how-to-check-if-a-element-of...

2 months ago | 0

| accepted

Answered

Z transfer fcn under simulink and cmd line

This appears to be due to a round off error in the denominator of the discrete transfer function input to Simulink. Try for exa...

Z transfer fcn under simulink and cmd line

This appears to be due to a round off error in the denominator of the discrete transfer function input to Simulink. Try for exa...

2 months ago | 0

| accepted

Answered

How do I create a colored intensity plot from location and intensity values

This is one approach % define x,y coordinates and corresponding z value x = rand(13,1) y = rand(13,1) z = x.*y % make eve...

How do I create a colored intensity plot from location and intensity values

This is one approach % define x,y coordinates and corresponding z value x = rand(13,1) y = rand(13,1) z = x.*y % make eve...

2 months ago | 0

Answered

How to repeat elements of a matrix

So is this what you want? A = rand(8,16); B = [repmat(A,1,31) A(:,1:4)]; In this case the last 4 columns of the 8 by 500 are ...

How to repeat elements of a matrix

So is this what you want? A = rand(8,16); B = [repmat(A,1,31) A(:,1:4)]; In this case the last 4 columns of the 8 by 500 are ...

2 months ago | 0

| accepted

Answered

Run MATLAB from excel

You should investigate this product https://www.mathworks.com/products/spreadsheet-link.html

Run MATLAB from excel

You should investigate this product https://www.mathworks.com/products/spreadsheet-link.html

2 months ago | 0

Answered

Inserting zeros for missing values in a vector

At line 22 on the right hand side you have the vector Vx which has 5 elements. On the left hand side you have newVx indexed by i...

Inserting zeros for missing values in a vector

At line 22 on the right hand side you have the vector Vx which has 5 elements. On the left hand side you have newVx indexed by i...

2 months ago | 0

| accepted

Answered

How do I add a time column in the format of YYYY-MM-DD to my table?

I think R stores dates as posix time. You can use something like this to convert to datetime format eg 31-Dec-1969 23:59:56 d ...

How do I add a time column in the format of YYYY-MM-DD to my table?

I think R stores dates as posix time. You can use something like this to convert to datetime format eg 31-Dec-1969 23:59:56 d ...

2 months ago | 0

| accepted

Answered

Combine 3 fig. graphs in one plot to compare each other

You should run each of the simulations keeping the results in local variables stored in the base workspace, and then plot the da...

Combine 3 fig. graphs in one plot to compare each other

You should run each of the simulations keeping the results in local variables stored in the base workspace, and then plot the da...

2 months ago | 0

Answered

Plotting 2 scripts on 1 graph

The results of running scripts are saved in the local workspace. So lets say that inside of script one you calcualate values of...

Plotting 2 scripts on 1 graph

The results of running scripts are saved in the local workspace. So lets say that inside of script one you calcualate values of...

2 months ago | 0

Answered

FMINCON - Include constraints provided by the objective function

You can use nested functions to avoid recomputing your constraint values. This topic is covered in the following documentation...

FMINCON - Include constraints provided by the objective function

You can use nested functions to avoid recomputing your constraint values. This topic is covered in the following documentation...

2 months ago | 1

Answered

How to get array user input in 1 dialog box

If I am understanding what you would like to do I think this might work. % Use single dialog box to collect all information, u...

How to get array user input in 1 dialog box

If I am understanding what you would like to do I think this might work. % Use single dialog box to collect all information, u...

2 months ago | 0

| accepted

Answered

Does anyone know which Simulink Block this is?

Right click on the block in question. This will bring up a context menu. Select "help" from the bottom of this menu. This will t...

Does anyone know which Simulink Block this is?

Right click on the block in question. This will bring up a context menu. Select "help" from the bottom of this menu. This will t...

3 months ago | 0

Answered

Toggle between temperature units for unit conversion

I think this does what you want. I have fixed a few errors in your original code, I think you were confused about the value of ...

Toggle between temperature units for unit conversion

I think this does what you want. I have fixed a few errors in your original code, I think you were confused about the value of ...

4 months ago | 0

Answered

How to run a model in simulink several times like a flowchart

You can use the MATLAB sim command to run Simulink programatically in a loop, please see https://www.mathworks.com/help/simulin...

How to run a model in simulink several times like a flowchart

You can use the MATLAB sim command to run Simulink programatically in a loop, please see https://www.mathworks.com/help/simulin...

4 months ago | 0

Answered

Create folders and organize data based on file name.

You should be able to select the ones you want using dir and wildcards so for example list = dir('*CP-B-01*.txt')

Create folders and organize data based on file name.

You should be able to select the ones you want using dir and wildcards so for example list = dir('*CP-B-01*.txt')

4 months ago | 0

Answered

Search for text in all .m files of a folder?

Use the "Find Files" function on the home tab of MATLAB main window

Search for text in all .m files of a folder?

Use the "Find Files" function on the home tab of MATLAB main window

5 months ago | 1

| accepted

Answered

Minimizing a function using fmincon with special constraints and intervals

Here is one approach % function to be minimized fun = @(x)x(1)^2 + 3*x(2)/x(3) - x(4)^2 ; %initial value x0=ones(1,4); %...

Minimizing a function using fmincon with special constraints and intervals

Here is one approach % function to be minimized fun = @(x)x(1)^2 + 3*x(2)/x(3) - x(4)^2 ; %initial value x0=ones(1,4); %...

5 months ago | 1

| accepted

Answered

Get shortest paths and distances among nodes without loop for (and possibly in a faster way)

for the distances (shortest path) between every pair of nodes in the graph d = distances(G) and for some subset, in your case ...

Get shortest paths and distances among nodes without loop for (and possibly in a faster way)

for the distances (shortest path) between every pair of nodes in the graph d = distances(G) and for some subset, in your case ...

6 months ago | 1

Answered

Matlab - Class : how to declare an internal function returning a value

You must tell MATLAB that findScenarioNumber is a member function of the class you are currently in scenarioNumber = obj.findSc...

Matlab - Class : how to declare an internal function returning a value

You must tell MATLAB that findScenarioNumber is a member function of the class you are currently in scenarioNumber = obj.findSc...

6 months ago | 0

| accepted

Answered

any idea how i can compute the elapsed time in each iteration in for loop ?

Use tic and toc

any idea how i can compute the elapsed time in each iteration in for loop ?

Use tic and toc

6 months ago | 0

Answered

Reading a specific file based on the input the user enters

You could do something like this % prompt user for test series number seriesNo = inputdlg('Please enter the test series number...

Reading a specific file based on the input the user enters

You could do something like this % prompt user for test series number seriesNo = inputdlg('Please enter the test series number...

6 months ago | 0

Answered

Midpoint between 2 numbers in 2 columns in the same csv file

% read in the data dat1 = readmatrix("File1.csv"); dat2 = readmatrix("File2.csv"); % assume first column matches, and compu...

Midpoint between 2 numbers in 2 columns in the same csv file

% read in the data dat1 = readmatrix("File1.csv"); dat2 = readmatrix("File2.csv"); % assume first column matches, and compu...

6 months ago | 0

| accepted

Answered

How can i plot this: x(t) = |t| * rect((t - 1)/3)

As far as I know, rect is not a MATLAB function. Perhaps it is one you defined and saved in an m file. Assuming this is the case...

How can i plot this: x(t) = |t| * rect((t - 1)/3)

As far as I know, rect is not a MATLAB function. Perhaps it is one you defined and saved in an m file. Assuming this is the case...

6 months ago | 0

Answered

Importing Excel Database Into MATLAB

I just ran T = readtable('dataset2.xlsx') and it seems to import without any problems

Importing Excel Database Into MATLAB

I just ran T = readtable('dataset2.xlsx') and it seems to import without any problems

6 months ago | 0

Answered

Find the value which is repeated in each row of a matrix (without loop for)

Here's another way % Input A = [ 523 2920 523 1227 8003 8343 5611 8343 ...

Find the value which is repeated in each row of a matrix (without loop for)

Here's another way % Input A = [ 523 2920 523 1227 8003 8343 5611 8343 ...

6 months ago | 1

Answered

How to discover the neighbor nodes in an matrix?

Here is a little example that I think does what you are asking % % assign threshold for being a neighbor dMax = 0.6; % mak...

How to discover the neighbor nodes in an matrix?

Here is a little example that I think does what you are asking % % assign threshold for being a neighbor dMax = 0.6; % mak...

6 months ago | 0