Interpolation is wrong?
Here is the corrected code: x=dep_cal2012; y=wc_average; ix = linspace(1, max(x), numel(y)); WC_interp = interp1(ix, y, x,'ne...

2 months ago | 0

Help to transform math formula to matlab
Using the vectorization: format long m=5; jj=1:m; XSum1 = sum(log(jj).*exp(jj.^2)) % Or alternatively Xs = log(jj).*exp(...

2 months ago | 0

Why Does "clear all" Impact Prior Commands in a Script?
In such cases, it is best to use: clearvars instead of clear all

2 months ago | 0

How to solve laplace transform for ODE with initial value condition
Here is the corrected code: syms t s y(t) Y(s) Dy = diff(y,t); EQN = t*Dy+y== cos(t); LT = laplace(EQN, t, s); LT = su...

2 months ago | 0

I have to find the local minima and maxima corresponding to the "peaks" and "valleys" of a data file.
Have you worked with fminsearch() fcn of optimization toolbox: https://www.mathworks.com/help/matlab/ref/fminsearch.html

2 months ago | 0

How can I use Lorenz Attractor code?
You simulated the code incorrectly. Here is how you should run the code in one m-file: ICs=[5, 5, 5]; % Your data t=[0, 20]; ...

2 months ago | 0

How can I make my ODE system run faster
Use a variable step solver instead of the fixed step, e.g.: options = odeset('mass',BigM,'MassSingular','no','BDF','on','MaxOr...

2 months ago | 0

Import Data Fails to open excel file
Use readmatrix() or readtable() which are much more efficient and faster than uiimport() or importdata() fcns that you have used...

2 months ago | 0

Question

How to combine two profiles
Hello MATHWORKS staff, Could you please post a procedure how to combine two different mathworks profiles into one? Thanks mu...

2 months ago | 0 answers | 0

### 0

How to plot graph with multiple values of x in a function
You may also consider to display a legend showing the number of x values taken for calc and plot in every iteration: count=0; ...

2 months ago | 1

How to plot graph with multiple values of x in a function
A small (but crucial) err that is elementwise operation needed, e.g.: count=0; for i=[3,5,7,10,20,100] count=count+1; ...

2 months ago | 1

how can i fit curve for transfer function
Laplace transform (LT) formulation is already an anaytical form solution and if you would like to get a new fit (rational polyno...

2 months ago | 0

How to save/store/recuparate data from inside a nested loop.
This can be done: for X=1:N_aoa initial=[0;aoa(X);0;0]; Y=[initial,zeros(4,N)]; for n=1:N ... %Stuff happens here ...

2 months ago | 0

How to plot values at particular column or row in a 2D matrix
% A is 1024 - by - 256 plot(A(:,250))

2 months ago | 0

| accepted

Solved

Change the sign of even index entries of the reversed vector
change the signs of the even index entries of the reversed vector example 1 vec = [4 -1 -2 9] ans = [9 2 -1 -4] example2...

2 months ago

Pasteing texts in Matlab script is not working

2 months ago | 0

| accepted

fmincon error occurs without details in Matlab
It is working ok. clearvars;clc; lb = [0, 0]; ub = [1, 1]; A = [1 1]; B = 1; Aeq = []; Beq = []; x0=[0.5, 0.5]; ...

2 months ago | 0

Combine data from 3 tables based on common datetime?
Here innerjoin does not work. It is better to employ a logical indexing approach, e.g.: % D1 is a first table array variable an...

2 months ago | 0

How to read data from excel to a cell?
You can get the data from *.xlsx with a few different data import fcns of matlab. Here are two most recommended data import fcns...

2 months ago | 0

Why do i get a empty matrix as a result?
There are a few errs (where the parameters are defined and how the output variable dv() is defined) in defining the function fil...

2 months ago | 0

How do I minimize a function graphically?
In your code, your variables are x1 and x2 and NOT x. Moreover, g1 and g2 are incorrectly defined. In this exercise, you shoul...

2 months ago | 0

How can I simulate a resource allocation?
According to what you have stated in your exercise description and understood, this code can be written: D = load('detected.mat...

2 months ago | 0

accuracy test higher than training
You can try to employ random selection of the data for training and validation using randperm() or randsample(), for example. A...

2 months ago | 0

FOR LOOP ERROR IN MATLAB
[for end] loop is working perfectly ok, but there is an error in your defined function's input arguments. See the corrections: ...

2 months ago | 0

Trying to solve equations within ranges
One of the viable solutions is to use symbolic math: syms and solve. clearvars; clc x1=-2; x2=2; y1=-2.1; y2=2.1; x = x1:0.1...

2 months ago | 0

| accepted

adding column ( cell) to matrix
x = (1:5).'; % Vector F1 = categorical({'A'; 'B'; 'C'; 'D'; 'E'}); % Cell Categorical Array F2 = ...

2 months ago | 0

How do I estimation of the means of a random variable?
% lower and upper bounds of the Uniform random variable X: a= 0; b = 2; % True values of the mean and variance of X: m = (b-...

2 months ago | 0

| accepted

How to retrieve the index of positions starting with a specific character in a cell array?
x1 = 5000; x2 = 3000; x3 = 1000; x4 = 800; x5 = 500; array1 = ([x1,x2,x3,x4,x5]).'; array2 = categorical({'A1';'A2';'B1'...

2 months ago | 0