Community Profile

photo

Davide Masiello


Paul Scherrer Institut (PSI)

Last seen: Today Con actividad desde 2017

Programming Languages:
MATLAB
Spoken Languages:
English, Italian
Professional Interests:
Chemical Kinetics, Fluid Dynamics, Chemical Engineering, Heat and Mass Transfer

Statistics

All
  • MATLAB Mini Hack 2022 Participant
  • Knowledgeable Level 5
  • Pro
  • Introduction to MATLAB Master
  • 3 Month Streak
  • Thankful Level 2
  • Knowledgeable Level 3
  • Solver
  • First Answer
  • Thankful Level 1

Ver insignias

Content Feed

Ver por

Respondida
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); ...

5 días hace | 1

| aceptada

Respondida
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...

9 días hace | 0

Respondida
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...

9 días hace | 1

| aceptada

Respondida
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...

10 días hace | 0

| aceptada

Respondida
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...

11 días hace | 0

Respondida
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...

11 días hace | 0

| aceptada

Respondida
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 =...

16 días hace | 0

| aceptada

Respondida
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

21 días hace | 0

Respondida
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...

alrededor de 1 mes hace | 0

Respondida
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 ...

alrededor de 1 mes hace | 0

| aceptada

Respondida
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...

alrededor de 1 mes hace | 0

Respondida
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(...

alrededor de 2 meses hace | 0

| aceptada

Respondida
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...

alrededor de 2 meses hace | 0

Respondida
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 ...

2 meses hace | 0

| aceptada

Respondida
How to form a matrix based on the order of input
Input= [110 101 011 111 100 001 010]; M = Input == sort(Input)'

2 meses hace | 1

| aceptada

Respondida
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...

2 meses hace | 0

Respondida
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...

2 meses hace | 0

| aceptada

Respondida
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...

2 meses hace | 1

| aceptada

Respondida
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...

2 meses hace | 0

Respondida
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...

2 meses hace | 0

Respondida
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...

3 meses hace | 0

| aceptada

Respondida
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)

3 meses hace | 0

Respondida
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...

3 meses hace | 0

| aceptada

Respondida
Loop plotting for individual years
There's no legend in the example below, because I am not sure what you wanted to do with the cellfun function. Nevertheless, it...

3 meses hace | 0

| aceptada

Respondida
How to vertically concatenate many tables produced from a for loop
I would try something like this M = []; for k=1:numel(A) % automatically brings in the correct amount of tables M = [M;re...

3 meses hace | 0

| aceptada

Respondida
Duplicating an entire vector
A=[1 2 3 4]; repmat(A,1,3)

3 meses hace | 1

Respondida
plotting graph with 2 different size of vector
Applying diff to a Nx1 array produces an (N-1)x1 array, hence your problem. In truth, you are not really calculating the deriva...

3 meses hace | 0

| aceptada

Respondida
Build a matrix with a gradual value of intensity and an horizontal line with a constant value
A = repmat(linspace(0,1,1000),500,1); A(220:280,:) = 0.5; imshow(A)

3 meses hace | 0

| aceptada

Respondida
removing specified data from variable
I think the following code is a simpler way of achieving your task, but it does not implement the "pulling a number from a rando...

3 meses hace | 0

Respondida
Call different functions inside a function
The way you have explained it in your question is already correct. See the example below. %% Main script mainfunction %% Mai...

3 meses hace | 1

Cargar más