Community Profile

photo

Davide Masiello


Paul Scherrer Institut (PSI)

Last seen: 20 dagen ago Active since 2017

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

Statistics

All
  • 3 Month Streak
  • Knowledgeable Level 4
  • Thankful Level 2
  • Knowledgeable Level 3
  • Solver
  • First Answer
  • Thankful Level 1

View badges

Content Feed

View by

Answered
max value in each row with its index
inputmatrix= [8.0000 0 7.3398 0 8.0000;... 1.6635 0.7103 3.2000 3.2000 3.2...

2 maanden ago | 0

Answered
Save for loop outputs into structure
Does allBIN(n).corr work?

3 maanden ago | 0

Answered
How to replace non consecutive value on a vector?
You could write a function that scans your array in search of the pattern you specify and replaces it with another. clear clc ...

3 maanden ago | 0

Answered
How to solve coupled partial differential equations with method of lines?
Hi @Ari Dillep Sai, take a look at the code below. The breakthrough now is found to be sometimes after 4000 s (or ~67 mins), so...

3 maanden ago | 0

| accepted

Answered
How to import multiple text files from multiple folders and take maximum from each text file
Hey @Nazanin Farsi, based on your replies, maybe the following code will work. n1 = 1:22; n2 = 0.1:0.1:1.3; max_value = zer...

3 maanden ago | 0

Answered
How to import multiple text files from multiple folders and take maximum from each text file
clear,clc n = 0.1:0.1:1.3; for k = 1:length(n) filename = [num2str(n(k)),'pga/AllMaxDrift.out']; data = read...

3 maanden ago | 0

Answered
Newtonian interpolation polynomial that interpolates f twice (value and 1st derivative)
If the problem is the error appearing in your question, i.e. Function definitions in a script must appear at the end of the fil...

3 maanden ago | 0

Answered
how to get x value of findpeaks
If X is your array of x-values, do [peaks,locs] = findpeaks(smoothed{i},'MinPeakHeight',0.5,'MinPeakDistance',200); x_peaks =...

3 maanden ago | 0

Answered
vector that displays [0 5 10 15]
Just be aware of the fact that you do not need to use a loop to do this A = 0:5:15 That said, if you really must use a loop, t...

3 maanden ago | 0

| accepted

Answered
Finding indices of a vector within a matrix
Let me propse the following example clear,clc A = rand(100); A = A > 0.5 B = cell(1,100); for col = 1:size(A,2) idxs...

3 maanden ago | 0

Answered
How to solve for three answers from 3 equations using fsolve
Below, see an example of how to solve the system. I had to make up the values of the constants since you have not specified the...

3 maanden ago | 0

| accepted

Answered
Adding every loop a matrix from the right side to a matrix
In the example below, a new 2x2 random matrix is created at each new iteration and appended to an existing matrix A. clear,clc ...

3 maanden ago | 0

Answered
assigning argument of function within function
The error is in the last line of the function fix. Change that and the code works. fix(rand(1,10)) % complete function funct...

3 maanden ago | 0

Answered
conversion of yes no into logical array
clear,clc T = readtable('gridstability.csv') If you are ok with T.stabf being populated by true/false values, you can use. T....

3 maanden ago | 0

| accepted

Answered
I have to create a square wave signal on simulink where any logical value, high or low, must last for a given time. Logical values and times are sent by other simulink blocks.
Maybe something like this? clear,clc T = [3,6,2,1,4,3,8]; V = [1,0,1,0,1,0,1]; % Block t = cumsum(T); t = [0,repelem(t...

3 maanden ago | 0

Answered
How do I find sin of a cell variable (el)?
If the value is stores in a cell, then you should write el{PRN,t} in order to extract the value as a double.

3 maanden ago | 0

Answered
Sort a variables in structure
See example below clear,clc s.var_1 = 1; s.var_6 = 1; s.var_3 = 1; s.var_2 = 1; s.var_5 = 1; s.var_4 = 1; s order...

3 maanden ago | 0

Answered
Runga-Kutta Method for system of first order differential equations
Two things: 1 - By defining two different functions for y1 and y2 you decouple the system, which is the source of the main prob...

3 maanden ago | 0

| accepted

Answered
Free Radical Polymerization for Copolymers AA and Styrene using pseudokinetic rate constants
You just need to calculate all the quantitites inside the ODE function as well. If you need those quantities to be plotted, the...

3 maanden ago | 0

| accepted

Answered
Fitting data to a known function using numerical solution
I suggest an extensive reading of the following documentation https://ch.mathworks.com/help/curvefit/fit.html https://ch.mathw...

3 maanden ago | 0

| accepted

Answered
2nd order diff equation for ode23/45?
The way you coded the ODE system is incorrect. See below clear,clc % Numerical solution tspan = [1 4]; y0 =...

3 maanden ago | 1

| accepted

Answered
Writing a loop to create a matrix
Example A = rand(3) n = 10; lambda = []; for i = 1:n lambda = [lambda;A.^i]; end lambda

3 maanden ago | 1

| accepted

Answered
Diagonal sums with non-zero elements
%define A A = [0 0.4 0.3 0.3; 0 0 0.5 0.5; 0.5 0.3 0 0.2; 0.5 0.3 0.2 0]; [n,n] = size(A); %find all permutations of A B =...

3 maanden ago | 1

Answered
how to count the number of lines of an external txt file
Not sure if there is a better way, but this will work fid = fopen('a.txt','r'); n = 0; while ~feof(fid) fgetl(fid); ...

3 maanden ago | 0

Answered
Plotting differential equations using ODEs with multiple initial conditions, trying to recreate a plot
I could not run the code, because several constants are missing (e.g. alpha1,beta1 etc.) The error in your code is that you hav...

3 maanden ago | 0

Answered
Unrecognized function or variable 'qdpfun"
Below, I show the right way to pass extra parameters to a function. clear,clc dP = -18*1.01325e5; dz = 100; rho = 1e3; ...

3 maanden ago | 1

| accepted

Answered
Can someone help me understand why I cant get a graph with an alpha of 0.001
Following @Jan comprehensive answer, I think a code like the one suggested below might be a good solution to your problem clear...

4 maanden ago | 1

Answered
find indexes of two values that between them there is specific number
clear,clc A = [1 5 3 10 38 27]; B = 2; % Interpolattion values idx = 1:2:2*length(A)-1; newA = interp1(idx,A,1:idx(end...

4 maanden ago | 0

Answered
Runge-Kutta for multiple variables
Hi @Juliana Quintana, the problem is that by defining 4 different function handles and 4 different loops, you have decoupled the...

4 maanden ago | 0

| accepted

Answered
How to make vector of Unicode characters align with 1x2 matrix of numbers
clear,clc playerCards = []; storeUnicode = []; allSuites = [9824 9827 9829 9830]; % all possible uni...

4 maanden ago | 0

| accepted

Load more