Answered
How to make this function accept a vector input
You function already accepts a vector input for ‘x’. x = linspace(0, 2*pi, 6); n = 42; y = sineseries(x,n) check = sin(x) ...

8 years ago | 0

Answered
Force Index to be in range
Try this: A = [0 1 2 3 7] i = -2 : 9 % Test Vector i = min(numel(A),max(i,1)) producin...

8 years ago | 0

| accepted

Answered
How to I limit the plot range to [0, 4]?
Use the axis (link) function.

8 years ago | 0

Answered
vpasolve returns empty syms 0x1
One option is to use solve first rather than vpasolve, then use vpa later. Example — S1 = solve(eqns, [I,A,t1x,tau,sigz,R1,...

8 years ago | 0

| accepted

Answered
Placing a tangential line at point of inflection for a data set.
How to draw tangent line at infleciton point? can provide you with one approach.

8 years ago | 1

| accepted

Answered
How to make calculations over an interval throughout an entire vector?
I would use the movmax function and its friends, or if you want to calculate the maximum or minimum over 100-element blocks of y...

8 years ago | 0

Answered
I'm getting error at function script must be closed with an end.
I recommend that you always use ‘Smart Indent’. (One way to invoke it is to highlight your code, then type Crtl+I.) It will au...

8 years ago | 1

Answered
Finding the mean of my entire data
If you have R2018b, use the 'all' argument: Avg = mean(MyMatrix, 'all') otherwise, convert it to a column vector and take the...

8 years ago | 0

Answered
Finding a mean for all my data
If you have a recent MATLAB release (definitely R2018b, possibly earlier), use the 'all' argument: matrix = rand(5,7) Avg = m...

8 years ago | 0

Answered
deleting rows from matrix and saving as a new matrix
Probably the easiest way: MTX_2 = MTX_1(setdiff(1:size(MTX_1,1),[2,7]),:) This creates ‘MTX_2’ while leaving ‘MTX_1’ unchange...

8 years ago | 0

Answered
setdiff with reptitions ?
Experiment with the ismember (link) funciton or if you are using floating-point numbers, ismembertol (link): A = randi(9, 1, 1...

8 years ago | 1

| accepted

Answered
Maximize a system of nonlinear equation
One approach: f = @(x) norm([x(1).^2 + 2*x(2) + x(3); exp(x(1)).*sin(x(2)) + cos(x(3))]); [X, fval] = fminunc(@(x)-f(x), ra...

8 years ago | 0

| accepted

Answered
How do I make make one pode plot form a MIMO State-Space equation
I doubt that combining them makes any sense from a control system perspective. Experiment with this approach: rng(0,'twiste...

8 years ago | 0

| accepted

Answered
is there a function that let me turn a rational function to a polynomial in matlab?
You are not using the tf function correctly. You need to specify that ‘xi’ is a continuous-time transfer function first, then y...

8 years ago | 2

| accepted

Answered
How do I plot this on MATLAB
A guess: ustp = @(t) t>0; % Unit Step Function mu = 100; V = @(t) 100*exp(-t/(100*mu)).*...

8 years ago | 1

Answered
Help using the arrayfun() function to apply strsplit() to all entries in a string array
Try this: for k1 = 1:size(weather_strings,1) Col3(k1,:) = str2double(regexp(weather_strings{k1}, '\d*\.\d*', 'match')); ...

8 years ago | 0

| accepted

Answered
Average data in an array based on corresponding time values
Try this: t = [3,1,5,6,2,1,3]; d = [352,59592,5783,27,6849,264,284]; [tu,~,ix] = unique(t); dmeans = accumarray(ix, d, [], ...

8 years ago | 1

| accepted

Answered
Trying to plot numerical solutions for systems of DEs
The reason is that ‘y’ is not defined in your function. One option is to code ‘x’ as ‘x(1)’ and ‘y’ as ‘x(2)’: f = @(t,x) [...

8 years ago | 1

| accepted

Answered
Delete rows with same elements
Try this: a=[2 3 2;3 3 3;4 4 4;2 5 4; 3 5 5; 4 4 4; 7 3 4]; a_new = a(all(diff(a,[],2) ~= 0, 2),:) If all the columns in a p...

8 years ago | 1

| accepted

Answered
how can i make ga code to set a specific values to a parameter
I am not certain what you are asking. If you have a parameter you want not to vary (you already know the optimum value), fix ...

8 years ago | 0

Answered
can anyone help me with "ode45" ?
Probably the easiest way would be to integrate your function first, the using the solved values for ‘t’ and ‘x’, run it again, r...

8 years ago | 0

Answered
how to find peaks for a graph plotted in semi-log axes and to extract the values of peak and FWHM?
Use findpeaks with more than 2 outputs: [pks,locs,widths,proms] = findpeaks(PeakSig,x); See the documentation section on Peak...

8 years ago | 1

| accepted

Answered
Mean of time series
Much depends on your data. If they all have the same values for the independent variable, you can use the mean (link) function ...

8 years ago | 0

Answered
How can I fill the area between these two curves? I tried using fill function along with the flipud and fliplr function but the problem is both the curves have different x and y value.s.
Try this: figure plot(x1, y1, x2, y2) hold on patch([x1; flipud(x2)], [y1; flipud(y2)], 'g') hold off They are column ...

8 years ago | 0

| accepted

Answered
How do i solve a cubic function giving the answer in a matrix
Try this: syms Z Pr = 42; % Choose A Number ... Zs = solve(0==((8*0.9)/(...

8 years ago | 1

| accepted

Answered
Replace corresponding elements in two different matrices
Try this: A = [1 2 3 4; 5 NaN 7 8; 9 10 11 NaN] B = randi(9, 3, 4) NewB = B NewB(isnan(A)) = NaN producing: A = 1 ...

8 years ago | 1

| accepted

Answered
Getting Empty sym: 0-by-1 when using solve function
Your code works for me: I = (pi*.015^4)/64; E = 200*10^9; syms x [x] = solve(0 == (1/(E*I))*((-199.46/2)*x^2 + (290/2)*(x-....

8 years ago | 0

Answered
Plotting a line between two points
You may need to transpose the (10x2) matrices for each column in order to plot them as you want. Try this (for the first colu...

8 years ago | 0

| accepted

Answered
I have a tf(num,den), and I need to obtain values like G(s)=y from it. Is there any function that allows me to do that?
Use the evalfr (link) function: num=[1 1 0]; den=[1 2 3 4]; G=tf(num,den); s1=2+3i; Gs1 = evalfr(G,s1) % G(s1)=???...

8 years ago | 1

| accepted

Answered
I wanna obtain numerical values from a tf(num,den). How can I do it?
Use the evalfr (link) function: num=[1 1 0]; den=[1 2 3 4]; G=tf(num,den); s1=2+3i; Gs1 = evalfr(G,s1) % G(s1)=???...

8 years ago | 1

| accepted

Load more