Answered
Interpolation across only 1 dimension for a multi-dimensional array
Use interp1(). The first input must be a vector; the second input can be an array of any size; permute() it so that you are inte...

2 years ago | 0

| accepted

Answered
Calculation of mortgage interest from the amount of the mortgage, annuity monthly installments and number of years
M = 100000; a = 8791.59; r = 1; syms x eqn = a == M*(x/1200*(1+x/1200)^(r*12))/((x/1200+1)^(r*12)-1) sol = solve(eqn, x); ...

2 years ago | 0

Answered
How to deal with files in which rows have different numbers of columns
You could readcell but I wouldn't recommend it. I would suggest using textscan with appropriate format for what you are expecti...

2 years ago | 0

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
This version of the code does more work than is necessary, but has the minimal change needed to prevent the particular error you...

2 years ago | 0

Answered
Split array into groups of close numbers
No -- because there is no rigourous meaning to what "close" means. For example, in [1 3 5 7], surely 1 is not "close" to 7, but...

2 years ago | 0

Answered
Operator '>' is not supported for operands of type 'cell'.
filename = 'T.xlsx'; opt = detectImportOptions(filename); opt = setvaropts(opt, [2:6,13:15,18:19], 'Prefixes', "'", 'Suffixes'...

2 years ago | 0

| accepted

Answered
Having multiple different bins in a histogram that don't overlap
Are you looking for bar with the 'stacked' option? Or are you looking for bar() with groups? Generally speaking, there are two...

2 years ago | 0

Answered
Can we generate best fitted nonlinear equation between 4 inputs and 1 output, if we dont know the equation initially
No, you cannot. There are multiple constructive proofs that if you have a finite number of points known to finite precision, the...

2 years ago | 0

Answered
Loading variables to a specifc workspace
How can i use the load command to load variables to a specific workspace MATLAB does not provide any way to do that. I would...

2 years ago | 0

Answered
Please optimize this code by using a loop to display the polynomial coefficients.
fprintf('p%d=%.8f.\n', K, z(K+1)) However, you are using different widths for different coefficients. You will need to build a ...

2 years ago | 0

Answered
FSOLVE requires all values returned by functions to be of data type double. showing while solving an algebraic equation in matlab ??
F and G are int() calls. Even if they evaluate to closed forms that were rational numbers, they have symbolic results. When you ...

2 years ago | 0

| accepted

Answered
Why I cant plot drawn in MATLAB app designer
while(1) n = n + 1; c = (a+b)/2; if (fx(c)*fx(a) < 0) ...

2 years ago | 1

Answered
kmeans with centroids from previous analysis
Yes, that looks good. I notice that you pass [] for the k value. That will probably not be immediately obvious to readers, but ...

2 years ago | 0

| accepted

Answered
Using the output of one run of a function as the input of another iteration of that function
would it be possible to make such a function run faster by, for instance, not overwriting "List" on each iteration? No. When ...

2 years ago | 1

Answered
converting float to integer makes problem
int64(y); That line takes a value of y as input, and creates a uint64 equivalent of the input value, and stores the value i...

2 years ago | 0

| accepted

Answered
convert a cell (Rx1 cell) to a vector (Rx1 double)
13 entries in the cell are empty. rows_check_n = load("rows_check_n.mat"); rows_check_n = rows_check_n.rows_check_n; % 270x1...

2 years ago | 1

Answered
problem after new license
In your workspace you have a variable named sqrt . You need to clear sqrt

2 years ago | 1

| accepted

Answered
Caused by: MATLAB expression '<output of containers.Map>' is not numeric.
costToPlant=zeros(); costToPlant = containers.Map('KeyType', 'double', 'ValueType', 'double'); You initialize costToPlant as a...

2 years ago | 0

| accepted

Answered
Problem opening a .hdf file
Functions to read HDF4 files are described at https://www.mathworks.com/help/matlab/hdf4.html

2 years ago | 0

Answered
Results are not as expected ode15s
dxds= [((x(1)*((permH2O/z)*(ph*x(1)-pl*yH2O)+((permN2/z)*(ph*x(2)-pl*yN2))))+((permH2O/z)*(ph*x(1)-pl*yH2O)))/x(3); ((x(2)...

2 years ago | 1

Answered
Is the Parallel Computing Performance sensitive to MATLAB Version?
parpool 'local' very likely used processes -- background thread pool had only just be introduced in R2021b. Here 'local' refers ...

2 years ago | 1

| accepted

Answered
use particle swarm optimization algorithm to optimize the optimal transmission path from cluster heads selected by each round of cluster routing protocol to sink
You want to optiooize the optimal transmission path. First thing you need to do is decide what you want to optimize. It is the ...

2 years ago | 0

Answered
I am attempting to code a function with a differential (temperature with respect to time) and i am unsure how to do so
You can pass T and to gradient() to get estimated derivative of . Multiply by , add Tj, result is . Transpose to get a column v...

2 years ago | 0

Answered
Unrecognized function or variable
U0 = 0.5640; That is a numeric value. ft = fittype('a*exp(b*x)+c*exp(d*x)+(U0-a-c)*exp(f*x)+g','coeff',{'a','b','c','d','f','g...

2 years ago | 0

Answered
Simulating a 2D Random Walk
Call simulateRandomWalk twice, once to get an x trajectory and once to get a y trajectory. Then put them together, plot(first_t...

2 years ago | 0

Answered
Why is there a significant difference in the assignment results of functions using "subs" and "feval"
syms z load FF.mat Th3 z3 = 0.0016:0.00022:0.006; T1 = vpa(subs(Th3,z,z3)); disp(vpa(T1.',14)) Th3f = matlabFunction(Th3); ...

2 years ago | 0

Answered
How to build a plot differential equations
n = 0;b=0; k = 1; a = 1; h = 0; p = 1; y(1)=0; y(2)=1; x=2; f=@(t,y)[y(2);y(2)+2.*n.*(1+a.*y(1).^3).*y(1)+k.^2.*(y(1)+b.*y(...

2 years ago | 0

Answered
How can produce this matrix?
For the sum of each column to be 1, and the elements are each 0 or 1, then it follows that for every column, there must be exact...

2 years ago | 0

Answered
i got this error "Index exceeds the number of array elements (1)." at the first line starting " U(j, n + 1, dt_index)" when the first loop completed for one time
for dt_index = 1:length(dt_values) dt = dt_values(dt_index); Nt = Nt_values(dt_index); You extract particular s...

2 years ago | 0

| accepted

Answered
How to get every term of a sum thats not multiplied by a convergent exponential function?
Not exactly what you asked, but syms t G = exp(-t)*cos(t) + 3*exp(-2*t)*sin(2*t) + 1/2*cos(4*t) + 1/5 mapSymType(G, 'exp', @(...

2 years ago | 1

| accepted

Load more