**Programming Languages:**

MATLAB

**Spoken Languages:**

English, Italian

**Professional Interests:**

Chemical Kinetics, Fluid Dynamics, Chemical Engineering, Heat and Mass Transfer

**Statistics**

RANK**155**

of 276,223

REPUTATION**694**

CONTRIBUTIONS

**5** Questions

**278** Answers

ANSWER ACCEPTANCE **
60.0%
**

VOTES RECEIVED**63**

RANK

of 18,595

REPUTATION**N/A**

AVERAGE RATING**0.00**

CONTRIBUTIONS**0** Files

DOWNLOADS **0**

ALL TIME DOWNLOADS**0**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

How to include NaN elements in an array based on a condition?

a = [2 4 6 12 14 18]; A = a(1):2:a(end); new_a = zeros(size(A)); idx = any(a'== A,1); new_a(idx) = a; new_a(~idx) = nan; n...

1 day ago | 0

Minimize the sum of squared errors between the experimental and predicted data in order to calculate two parameters

You can use MatLab's fmincon. z = [0.006;0.012;0.018;0.024;0.03;0.046;0.069;0.091;0.122;0.137;0.152;0.162]; u_exp = [0.709...

2 days ago | 0

| accepted

Why do I receive "Not enough input arguments"? or How can I better code this ODE?

Here's a correct version of your code. 1) Time span and initial conditions must be in the same file as the ode solver, not sure...

17 days ago | 1

I have solved a set of three coupled odes in MATLAB. I have to plot another function which is a function of one of these odes. How this can be done?

If none of the differential equations you are solving depends on deln, then you can compute it after solving the ODE system. To...

28 days ago | 1

| accepted

In this code, I want to find out slope at every value of x?

You could use the gradient function provided by MatLab. x=[10.33 10.331 10.332 10.333 10.334 10.335 10.336 10.337 10.338 10.339...

1 month ago | 0

How to plot scatter plot with conditions?

data = readmatrix('table.xlsx'); time = data(:,1); PW = data(:,2); You can identify all the indexes for which the differenc...

1 month ago | 0

| accepted

How do I exclude values in linspace?

Hi @lea.c, I have several comments about your code. 1) MatLab already implements a function called integral, so I would recomme...

1 month ago | 0

Loop over initial guesses with fsolve

Try with func=@f; x0=[1:0.1:1.9;1:0.1:1.9;1:0.1:1.9;1:0.1:1.9;0.01:0.01:0.1;0.01:0.01:0.1;0.01:0.01:0.1]; x = zeros(10,7); ...

2 months ago | 1

| accepted

Help with numerical integral

I guess this is what you're looking for e=0.1; f=@(x)exp(x)./(1+x); a=0.5; b=1.1; n=2; h=(b-a)/n; i=1:1:n-1; S=f(a...

2 months ago | 0

Legend with certain number of rows and columns

Use legendflex from file exchange. x = linspace(0,1,1000); n = (1:6)'; y = x.^n; p = plot(x,y); title('y = x^n') legendf...

2 months ago | 1

| accepted

Creating a row vector of combinations?

You could use nchoosek. The example below is from -3 to 3 for memory issues (you'll generate a humongous matrix). Just substitut...

2 months ago | 0

| accepted

How to remove the zeros from the array upon breaking out of the for loop?

Would this suit your purpose? RHo = 0.5; % Relative Humidity air [%] M= 0.018; % molar mass of water mol...

2 months ago | 0

How o define two different data set of (t , T) for an ode solver that it's variables are (t , C)?

I think your code is fine, below you can see a slightly different approach that uses interpolation to define the T(t) dependence...

2 months ago | 0

| accepted

Create a row vector comparing strings in a for loop

index = []; s1 = { 'FMO1','FMO2','FMO3','FMO4', 'BAO1', 'BAO2', 'BAO3', 'BAO4'}; s2 = {'mean','FMO1','BAO4','FMO2'}; for k =...

2 months ago | 0

| accepted

Plot u=f(x,y,z) with all discrete data

x = rand(1,100); y = rand(1,100); z = rand(1,100); u = rand(1,100); scatter3(x,y,z,20,u,'filled') colorbar

3 months ago | 0

How can i delete max values for each 5 rows in vector

The following code will apply to any lenght of A and any length N of window from which to delete the maximum, provided that leng...

3 months ago | 0

Why the out varies largely in fixed versus variable time step?

That is because the fixed time step is not able to resolve the very steep change in the variable value that is clearly shown in ...

3 months ago | 0

| accepted

Find elements having a specific row and column numbers in a matrix

If the answer is the diagonal, then I'd use the diag function. However, if you are still interested in generalizing the code, y...

3 months ago | 0

How can we plot different signals S1 S2 and S3 on same y-axis with different values? I have attached a figure for reference.

Assume you have three signals which may overlap when plotted like so x = linspace(154,157,100); s1 = rand(1,100); s2 = rand(...

4 months ago | 0

| accepted

A table of s versus t.

There are a couple of errors in your code. First, the way you define the array t. Second, for array operations, use the dot no...

4 months ago | 0

A compact way to (i) sum two rows and two columns and then (ii) remove one of the two summed rows and one of the two summed columns

Your way is already quite compact. Maybe what you want to avoid is having to concatenate. Then, you could try this. x1 = [1 0 ...

4 months ago | 0

| accepted

How to form a matrix based on the order of input

Input= [110 101 011 111 100 001 010]; M = Input == sort(Input)'

4 months ago | 1

| accepted

function handle as array

That's because mtimes(a,b) = a*b, and if a is 4x4 and b is 4x1 than the operation yields a 4x1 array. I think what you might wa...

4 months ago | 0

Identify the duration of zero values and count the number of such zero regions

Use regionprops time = 0:100; signal = rand(size(time)); signal([3:6,15:21,43:55,61:64,87:92]) = 0; plot(time,signal) r = r...

4 months ago | 0

| accepted

How to count number of ones and zeros in a binary number?

I will assume that your binary numbers are stored as a character array, which is how Matlab normally works, e.g. A = dec2bin(20...

4 months ago | 1

| accepted

Solving a differential equation

Since you have data for V and C you could fit them with the analytical solution of the differential equation. Let's assume this...

4 months ago | 0

solving a dynamic equation

Hi @sam - you did not provide enough info for us to try and give a complete answer, but I did some guessing and came up with a s...

4 months ago | 0

Forward Euler solution plotting for dy/dt=y^2-y^3

There are a couple of issues with your code 1) Indexes in MatLab start at 1, not 0, so y(0) is not valid syntax and must be rep...

5 months ago | 0

| accepted

Dot indexing is not supported for variables of this type.

You are assuming that sh_16_data is a structure. Instead, do sh_16_freq = sh_16_data(:,2)

5 months ago | 0

find columns adjacent to logical values

Reductive example. Assume this is your matrix A = rand(10,5) and let's assume your logical criteria is that you want to extra...

5 months ago | 0

| accepted