Answered
partition column randomly in to three columns
The three parts has "almost" equal number of elements A=rand(10000,1); % dummy test data G=splitapply(@(x){x},A,randi(3,size...

4 years ago | 0

Answered
How can I zoom in/out in a plot with two x axes?
Probably using linkaxes hAx1 = gca; hAx = axes('Position',hAx1.Position,'XAxisLocation','top','YAxisLocation','right','color',...

4 years ago | 1

Answered
Nonlinear differential equation with unknown parameter
Solving up to PsiMax = 1000; which returns V = 0.823. Still not recommended to set PsiMax too large, just to show a more robust ...

4 years ago | 0

Answered
How to get_ride of NaN values in a cell?
IMH this is correct statement inside the double for-loop e{ii, kk}=a(a(:, ii)>L_lim(:,kk) & a(:,ii)<U_lim(:, kk), ii);

4 years ago | 0

| accepted

Answered
help ! how do i fix this error : Error using .* Integers can only be combined with integers of the same class, or scalar doubles.
Add cast to double statement after reading your image im=imread(' image.png'); im = double(im); ...

4 years ago | 0

Answered
Create least squares fit for linear combinations
first write a2 = 1 - a1 replace in the first equation with y, solve for a1, then a2

4 years ago | 0

Answered
generate random number between positive and negative and sum of this number is zero
You probably need this: https://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum

4 years ago | 1

| accepted

Answered
Subtracting polynomial from piecewise polynomial
x=cumsum(rand(1,5)); x = x-mean(x); % Test pp y=rand(size(x)); pp=spline(x,y); % Here is ppsubx2 a pp-form of pp-x^2 x0=...

4 years ago | 0

| accepted

Answered
Is there a faster way to implement a FIFO (queue) ?
If you don't need to retreive the whole FIFO in order, but read and write element by element, then the best way is NOT rearrange...

4 years ago | 0

Answered
how can i do Matrix multiplication with 3 matrices
sum(x.*rij,2)' * ai

4 years ago | 0

| accepted

Answered
How can I generate random integers from 1 to 'n' in a jagged array(matrix of different row size) ?
n=4; % number of "circuit" m=15; % tubes c=mat2cell(randperm(m),1,diff([0, sort(randi([0,m-n],1,n-1)), m-n])+1)

4 years ago | 0

| accepted

Answered
Array multiplication returning single value
"What am I missing?" Use elementwise multiplication ".*" and not matrix multiplication "*" (remove the double quote).

4 years ago | 0

Answered
Solving a 6th order non-linear differential equation in Matlab
Using bvp4c eta0 = 10; eta = linspace(0,eta0,100); yinit = [1e4;0;0;0;0;0]; solinit = bvpinit(eta,yinit); sol = bvp4c(@fun_...

4 years ago | 0

Answered
How to slice an outer surface plot to reveal an inner surface plot in MATLAB?
Use NaN to remove points you don't want to see, adapt to your need [X,Y,Z] = peaks(75); [Xa,Ya,Za] = peaks(50); Z(X<0 & Y<0) ...

4 years ago | 1

| accepted

Answered
Reduce a matrix to unique values, randomly choose which values are discarded
% Dummy data A=randi(10,52,5); [~,~,J]=unique(A(:,1)); r=(1:size(A,1))'; rr=accumarray(J,r,[],@(r) r(randi(numel(r)))); r...

4 years ago | 0

| accepted

Answered
Dot product of tensor
If you have the R2022a, a single statement will do A=rand(2,3,3); B=rand(4,5,3); C=tensorprod(A,B,3); size(C)

4 years ago | 2

| accepted

Answered
which function to us to check if a struct name exists
try/catch after reading your struct try data = a.b.c.d; catch try data = a.b.x.d; try ...

4 years ago | 0

Answered
How can I assign values to a Structure with multiple subfields with one line of code?
Not sure about your claim of one statement is faster than for loop. Whatever here is oneline code Exampe = struct() [ExampleSt...

4 years ago | 0

Answered
Is the .tiff structure in Matlab 2020a and Matlab 2020b/2021 different?
MATLAB has several ways to write tiff file, imwrite, print, Tiff class, etc... Which function are upu using and what type the da...

4 years ago | 0

| accepted

Answered
which function to us to check if a struct name exists
Use function isfield

4 years ago | 0

| accepted

Answered
How to find the matchings of the given graphs?
See if the maxmatching FEX can be useful for you.

4 years ago | 0

Answered
Calculating the eigen vectors without using eig function but using a data set, the transpose of the data set and a unit vector
Your method give you the largest singular vector not eigen vector: A=rand(5); C=A'*A; u=randn(size(A,2),1); u=u/norm(u); ...

4 years ago | 0

Answered
Why do I have 2 version installed after update?
You can uninstall the older version, but shouldn't disavtivate MATLAB license on your computer.

4 years ago | 1

| accepted

Answered
How to distribute data as Gaussian?
May be this thread can help you https://fr.mathworks.com/matlabcentral/answers/1677599-how-do-i-generate-a-random-number-betwee...

4 years ago | 0

Answered
Find minimal possible term x by trying out various combinations of other terms for a known sum
You need first to formulate your problem in consist unambiguous math problem. So I unstand you have an array A with n-numbers ...

4 years ago | 0

| accepted

Answered
Lagrange multiplicator with discrete constraints converges to local minimum
So you try to be smart and expect to find the minimum of a function 9 distinct points in {-1,0,1} x {-1,0,1} using continuous gr...

4 years ago | 0

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
You get coding errors at least in this two lines f=@(x) 1./(x.*(4-(9*x))); ... int1(m+1)=w1*f(x1)

4 years ago | 0

Answered
How to use a code that uses FFTW in MATLAB?
After I generate the code, how can I use it as a part of my MATLAB code? Is the generated code intended to be used in an executi...

4 years ago | 1

| accepted

Answered
how to repeat [5,4,3,2,1.....] infinitely?
A meta-array: x = rep5to1(100:120) %% function x = rep5to1(i) a=5:-1:1; x = a(mod(i-1,length(a))+1); end

4 years ago | 0

Answered
Create vector with unique values
Rejection method, it likely needs a single iteration n = 5000; while true r = unique(1+rand(1,round(n*1.1))); p = le...

4 years ago | 2

Load more