Answered
How do you express this function in MATLAB syntax ?
f = exp(x)+sin(5*x) ; % define x before f = @(x) exp(x)+sin(5*x) ; % call by f(value) This is called Anonymous function

6 years ago | 1

| accepted

Answered
Get all the values from a two (for loop)
clear all; clc; d=1:5; g=1:5; m = 5 ; n = 5 ; x = zeros(m,n) ; % initilization for i=1:5 for j=1:length(g) ...

6 years ago | 0

| accepted

Answered
How to draw this graph?
Read about xticks for labelling x1, x2 along the axes. I have taken random points for plotting. You can take your required point...

6 years ago | 0

| accepted

Answered
How to take values from a data corresponding to specific value
Read about interp1. You can use interpolation and get it. Also you can use logical indexing. But I prefer interp1. Let A be ...

6 years ago | 0

| accepted

Answered
How to plot the vibration mode shapes after obtaining the vibration mode values?
plot(v(:,i)) The above plots your eigen vectors. You can have a look on this function. https://in.mathworks.com/matlabcentr...

6 years ago | 0

Answered
Different coloured markers based on values
YOu have to use logical indexing. USe ineualities and plot them. figure hold on plot(x(y<0.05),y(y<0.05),'sr') plot(x(y>=0....

6 years ago | 2

Answered
Understanding Index for loop
Becuase the values you are saving are different......in the value b_j If you see you have used idex i.; so only the last value ...

6 years ago | 0

Answered
Different number of elements error
FactoredAmplitude(FactoredAmplitude > 0) = CrackSkewAngle(FactoredAmplitude > 0);

6 years ago | 1

| accepted

Answered
Splitting a vector at sign change
K = [1 2 3 4 5 6 7 8 -1 -2 -3 -4 -5 -6 -7 -8 1 2 3 4 5 6 7 8] ; K = K' ; S = sign(K) ; C = mat2cell(S, diff([0; find(diff(S...

6 years ago | 0

| accepted

Answered
Figure line won't show
Whereever you have y try converting them into double using: y = double(y) ;

6 years ago | 0

Answered
Replace certain elements of vector with the values from another vector (average the values belonging the same position)
A = [0 0 0 0 0] ; B = [5 6 4] ; C = [2 5 2] ; [c,ia,ib] = unique(C) ; for i = 1:length(c) A(C(ib==i)) = mean(B(ib==i...

6 years ago | 1

| accepted

Answered
How to reshape my matrix A to B
B = reshape(permute(A,[2 1 3]),3,[])'

6 years ago | 0

| accepted

Answered
how to find roots of 10*5 matrix
Let A be your 10*5 matrix. Where the coefficients are in rows [m,n] = size(A) ; r = zeros(m,n-1) ; for i = 1:m r(i,:) = r...

6 years ago | 0

Answered
Loading data from several subfolders
This question is asked infinite times and discussed to death. Just a google will give you tons of links. https://in.mathworks....

6 years ago | 0

Answered
repeated numbers in roots
iwant = unique(w)

6 years ago | 1

Answered
How to simplify this code?
X = 1:10 ; X10 = zeros([],1) ; for i = 3:10 X10 = [X10 X(i)] ; end The above can be simply achieved using: X10 = X(3:1...

6 years ago | 0

| accepted

Answered
A Varying matrix name in loop
N = 10; matrix = cell(N,1) ; for i = 1:N matrix{i} = rand(3) ; end Trust me, there is no meaning in naming as matrix...

6 years ago | 1

| accepted

Answered
Finding Corresponding x axis values of a constant curve on Y-axis
Let (x,y) be your data. Where y is cylpressure Dont use [y,x] = max(cylpressure); Rather, use: [val,idx] = max(cylpressure);...

6 years ago | 0

Answered
Plot only adjacent points that are close to each other
Have a look on knnsearch. This function gives you the nearest points/ points specififed by a certain distance for a given set of...

6 years ago | 0

Answered
How to deal the points on matrix with specific width size using Matlab?
If you know the dimensions of the Result_matrix you can initialize it either zeros or NaNs or ones. Depending on your requiremen...

6 years ago | 1

Answered
cumulative geometric average returns
Let R be your array of size 1*n. iwant = cumprod(1+R).^(1./(1:n))-1

6 years ago | 0

Answered
Why do I get this error? "indices must either be real positive integers or logicals."
You need not to use syms. there is no requirement of syms. You need not to use indesing N(g), this is not reuqired also this i...

6 years ago | 0

| accepted

Answered
Sum rows of a matrix based on conditions.
% data for demo A = [1 0.5 ;1 0.4 ; 2 0.1 ; 1 0.3 ; 2 0.5 ; 3 0.9 ; 3 0.6] ; [c,ia,ib] = unique(A(:,1)) ; % get unique fir...

6 years ago | 0

Answered
how to plot cell array in a for loop?
figure hold on for i=1:12 for j=1:5 scatter(a{j,i}) end end

6 years ago | 0

Answered
How many white pixels in selected pixels?
If A is an array and you want to find how many values > 200 use: nnz(A>200)

6 years ago | 1

Answered
How can we find the doubling time of a curve?
There is a formula for doubling time, if (n1,x1) and (n2,x2) are two data points selected, then doubling time Td is given by: ...

6 years ago | 0

| accepted

Answered
MATLAB program to compute the potential in a square region by solving Laplace’s equation using the Finite Difference (FD) approximation method.using the “surf” and “contour” MATLAB commands
Just rectifies the error you said: clc; clear all ; clear all; [X,Y] = meshgrid(linspace(0,1,20)); V = zeros(size(X)); [M,...

6 years ago | 0

Answered
I want to contour plot X,Y coordinate of temperature distribution heat map, the data field is a ring...
load("data.mat") ; % Get center of circles C = [mean(x) mean(y)] ; % Get radius of inner circle dx = C(1)-x ; dy = C(2)-...

6 years ago | 2

| accepted

Answered
Vector projection on a Plane
Refer here: http://www.nabla.hr/CG-LinesPlanesIn3DB5.htm Edit @Rik (2025-06-03): apparently the website has changed to somethin...

6 years ago | 1

Answered
How to change the following code to loop
Perfect ...get back here if you have doubts in the present code.

6 years ago | 0

Load more