Answered
Data Analysis - Matlab Code
D = randi([-5, 5],4,2) Cn = eye(size(D,1))-1/size(D,1)*ones(size(D,1)) D_centered = Cn*D mean(D_centered,1)

3 years ago | 1

| accepted

Answered
How to find x value for a known Y in array?
x = 0.1:0.1:4*pi-0.1; y = sin(x); i = find(y(1:end-1).*y(2:end) <= 0) x_root = x(i)-y(i).*(x(i+1)-x(i))./(y(i+1)-y(i)) [pi,2...

3 years ago | 0

| accepted

Answered
How do I convert a cell array with multiple values per cell into a numerical array with multiple rows?
n = 13; C = cell(1,n); for i=1:n C{i} = rand(5,1); end A = cell2mat(C) class(A)

3 years ago | 1

Answered
Hello everybody. I need your help. I need to display an image (.jpg) and would like it to close after 5 seconds. How could I do?
https://de.mathworks.com/matlabcentral/answers/1614610-how-to-display-any-image-for-500-ms

3 years ago | 0

Answered
How can I add two curves that don't share the same x-axis values?
T = union(t1,t2); Y1 = interp1(t1,y1,T,[],'extrap'); Y2 = interp1(t2,y2,T,[],'extrap'); diffY = Y1-Y2 plot(T,diffY)

3 years ago | 0

| accepted

Answered
using x vector input to find corresponding y value
Three possible solutions: x = [-2:0.5:16.5]; y = findingy1(x); figure(1) plot(x,y) y = findingy2(x); figure(2) plot(x,y) ...

3 years ago | 0

Answered
Find the rows have two same elements from a matrix
A = [1 9 8 2 7 8 5 8 9 6 5 4 7 3 8 5 4 8]; [I,J] = meshgrid(1:size(A,1),1:size(A,1)); [rows cols...

3 years ago | 0

| accepted

Answered
Why am I getting inf even though there is no divide by zero?
while 1 Pi_sat=A-B./(to+C) alpha=Pi_sat/Pi_sat(k) ... instead of while 1 for i=1:n ...

3 years ago | 0

Answered
Issue defending a variable in MATLAB APP Desinger
If fs is a vector of values, you have to use elementwise division: 1./fs instead of 1/fs Same for m_k = app.amp.*cos(2*pi*...

3 years ago | 0

| accepted

Answered
I want to multiply a vector by a number and calculate the sum of all the values.
A = [18;15;125;48;78;69;48;15;12;2]; s = cumsum(A)

3 years ago | 1

Answered
Integration of Numeric Data in cycle
Work on your data first so that you get a closed, non-overlapping curve. Especially "clean" the upper and the right part. Then a...

3 years ago | 0

Answered
How to set Dirichlet boundary condition on 1-D poisson equation FEM
It is hard to follow your coding, but my guess is that the boundary conditions at both ends are not incorporated in the linear s...

3 years ago | 0

Answered
Plotting a multivariable function, that also has a summation
xstart = 0.0; xend = 1.0; nx = 100; tstart = 0.0; tend = 5.0; nt = 100; nsum = 31; X = linspace(xstart,xend,nx); T...

3 years ago | 0

| accepted

Answered
while loop or loop
prompt = "Input x "; x = input(prompt) while x > 2500 && x < 2501 disp("Wrong value for x") disp("x must not be in the i...

3 years ago | 0

Answered
How can I find the coeficients alpha, beta of the simple linear regression, using polyfit function?
x = (0:0.1:1).'; y = 3*x + 4 + 0.01*randn(numel(x),1); polyfit(x,y,1)

3 years ago | 0

| accepted

Answered
How can I find the coeficients alpha, beta of the simple linear regression, using "\" operator
x = (0:0.1:1).'; y = 3*x + 4 + 0.01*randn(numel(x),1); A = [x,ones(size(x))]; b = y; coeffs = A\b; coeffs(1) coeffs(2)

3 years ago | 0

Answered
ODE-Runge Kutta
Maybe of interest for comparison. Seems we get different results - also for the code with only backward differencing. But this ...

3 years ago | 0

Answered
Find which columns have duplicates
Transpose the matrix :-) Or: ColumnsWithDuplicates = find(arrayfun(@(i)(~isequal (length (unique (A(:,i))), size(A,1))), 1:siz...

3 years ago | 0

Answered
Multiple 3d random walks
lambda = 3; %Mean free path numberOfSteps = 10000; % Total number of steps numberOfPaths = 3; % Number of paths x(1,:) = ra...

3 years ago | 1

| accepted

Answered
Laplace Inversion Of Bessel Function
Try the numerical way of finding the inverse Laplace transform: https://de.mathworks.com/matlabcentral/fileexchange/39035-numer...

3 years ago | 0

| accepted

Answered
Error using / .
If T is an array of multiple temperatures, you have to use elementwise division: k = k0 * exp((-Q) ./ (R*T)) instead of k = k...

3 years ago | 0

Answered
How to implement this coupled ODE
clc,clear,close all global Ve Cd A_r g g = 9.8; % m/s^2 Cd = 0.47; r = 3.7; % m A_r = pi * r^2; rho_fuel = 1000;...

3 years ago | 0

Answered
Solving ODE with boundary conditions
You have a first-order ODE. For first-order ODEs, you can prescribe one boundary condition, not two. Or one of the parameters ...

3 years ago | 1

Answered
Help with non linear equations.
fun = @(x)[8.07-(x(1)-x(2)+x(2)*0.9^(-1/x(3)));11.82-(x(1)-x(2)+x(2)*0.5^(-1/x(3)));284.23-(x(1)-x(2)+x(2)*0.1^(-1/x(3)))]; x =...

3 years ago | 1

| accepted

Answered
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
k1=180; k2=50; k3=220; knew=linspace(k1*0.4,k1*1.6,20); m1=1.1; m2=3.4; for i=1:length(knew) K{i}=[knew(i)+k2,-k2;-k2,...

3 years ago | 0

Answered
How do i plot two graphs in the same figure without it telling me that the vectors must be the same length?
Use figure; scatter(Stroom,Spanning_fit); hold on Stroom1 = 0:5:140; Spanning_fit = Stroom1*...

3 years ago | 0

| accepted

Answered
Passing arguments through a function
x = -5:1:5 disp(TopFunction(@(x)lin(x,1,2),x)) disp(TopFunction(@(x)square(x,1),x)) function y = TopFunction(func,x) y = f...

3 years ago | 0

Answered
Why is my code showing output as an array instead of single value?
If your inputs and the variable t are scalar values, A cannot be an array. My guess is that you specified t as a vector. %A ch...

3 years ago | 0

Answered
error because "pkg load symbolic"
In MATLAB, you don't need to load a package: pkg load symbolic This is an octave command. In MATLAB, either you have a licenc...

3 years ago | 0

Answered
solving system of non-linear equations for array of variables gives 0x1 syms
The numerical solver does not find a solution. Are you sure a solution exists ? epsilon0 = rand(3,1); P = 0.05; options = op...

3 years ago | 0

Load more