
Davide Masiello
Paul Scherrer Institut (PSI)
MATLAB
Spoken Languages:
English, Italian
Professional Interests:
Fluid Dynamics, Chemical Kinetics, Chemical Engineering, Heat and Mass Transfer
Statistics
RANK
228
of 262,714
REPUTATION
356
CONTRIBUTIONS
5 Questions
160 Answers
ANSWER ACCEPTANCE
60.0%
VOTES RECEIVED
34
RANK
of 17,985
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
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 months ago | 0
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 ...
2 months ago | 0
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...
2 months ago | 0
| accepted
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...
2 months ago | 0
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...
2 months ago | 0
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 months ago | 0
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 months ago | 0
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 months ago | 0
| accepted
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 months ago | 0
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 months ago | 0
| accepted
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 months ago | 0
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 months ago | 0
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 months ago | 0
| accepted
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 months ago | 0
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 months ago | 0
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 months ago | 0
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 months ago | 0
| accepted
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 months ago | 0
| accepted
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 months ago | 0
| accepted
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 months ago | 1
| accepted
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 months ago | 1
| accepted
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 months ago | 1
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 months ago | 0
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 months ago | 0
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 months ago | 1
| accepted
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...
3 months ago | 1
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 months ago | 0
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 months ago | 0
| accepted
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 months ago | 0
| accepted