Answered
Extracting coefficient Matrix and vector from available polynomial Expressions with exponential terms
You have not shown what you already tried or what the results were. In R2019a, this is possible with a for loop (since coeffs...

7 years ago | 0

| accepted

Answered
Fit Data to a Polar Equation
I have no idea what ‘general polar funciton’ you are referring to. If you have a particular function, you can likely fit your d...

7 years ago | 0

Answered
How to calculate the middle value
Try this: v = 200:-10:0; vstr = movmean(v,2); % Using ‘movmean’ (R2016a+) vstr = filter([1 1],2, v); ...

7 years ago | 0

| accepted

Answered
How to extract information from sys
The system object is a structure array of cells, so: N = sysD.Numerator{:} D = sysD.Denominator{:} produces: N = 1 ...

7 years ago | 0

| accepted

Answered
2D contour plot with data in Matlab
Yoiur data are gridded. You only need to reshape your vectors to get the matrices necessary for any contour or 3D plots you wan...

7 years ago | 0

| accepted

Answered
how to create date variable or column
Your data have a two-digit year. Assuming ‘10’ means ‘2010’, try this: D = xlsread('data.xlsx'); Col4 = datetime(fliplr(D)+[...

7 years ago | 0

| accepted

Answered
convert large number to smaller
One approach: f = @(x) round(x.*10.^floor(1-log10(abs(x))),2); producing: x = [3.2692e+17; 3.2692e+16; 4.2516E+8]; Result ...

7 years ago | 0

| accepted

Answered
how to find local minima of a graph like shown in the figure?
If you have R2017b or later release, the islocalmin (link) function is an option. Your are correct in using findpeaks with yo...

7 years ago | 2

| accepted

Answered
Add a number of variable values next to their corresponding vertical lines in a plot
I am not certain what result you want. Without your Excel file, it is necessary to make up a waveform. I would use the text ...

7 years ago | 1

| accepted

Answered
Find only peaks of interest
Your best option is to use two separate calls to findpeaks with different 'MinPeakHeight' arguments for each. The first one wou...

7 years ago | 0

Answered
Array indices must be positive integers or logical values
This line throws the error: w = I(b(1-((n-a)/a)^2)^.5)/I(b) To begin with, ‘I’ is not defined in your code. That aside, ‘b...

7 years ago | 0

Answered
Array indices must be positive integers or logical values!
‘suggestions?’ For one, post more of your code so the line you posted has a context. I suspect that ‘PredictRPM1sec’ is ...

7 years ago | 0

| accepted

Answered
Logical Indexing with Complex Numbers
The only approach I can suggest is: A = rand(5) + 1j*(rand(5)*eps + rand(5).*(rand(5)>0.5)); % Create ‘A’ Ar = real(A); A...

7 years ago | 1

| accepted

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
The ‘Pk_prev’ variable is a (2x2) matrix. You cannot assign that to a scalar array element in ‘P’. If you preallocate ‘P’ as...

7 years ago | 1

| accepted

Answered
funtion handle in for loop
What do you want to do? Your code integrates a scalar (that you define as f(i)), so integral throws an error because it wants...

7 years ago | 0

Answered
semilogx() with reverse X Axis changes Y Labels position
That is a bug that has been fixed in R2019a (and perhaps earlier). The only workaround seems to be to create separate 'YTickL...

7 years ago | 0

| accepted

Answered
Finding frequency corresponding to some gain in magnitude plot of bode
Try this: s = tf('s'); G = 144000/(s*(s+36)*(s+100)); [mag,phase,wout] = bode(G); mag = squeeze(mag); phase = squeeze(ph...

7 years ago | 7

| accepted

Answered
Calculate an expression in MAtlab
It depends on what ‘T’ and ‘c’ are. If they are scalars, this would likely work: T = rand; c = rand; x(1) = rand; N = 10...

7 years ago | 0

| accepted

Answered
How to change interval of x axis
You can define the 'XTick' values: plot(years,annual_ridership,'o', xx,yy) set(gca, 'XTick',years) ...

7 years ago | 1

| accepted

Answered
Index in position 1 exceeds array bounds (must not exceed 1)
Your ‘E2’ and ‘Ent_dept’ variables are both (1x4) vectors. They are not matrices, so you cannot use row and column subscripts t...

7 years ago | 1

| accepted

Answered
I need help building bandstop filter to filter noise from my wav file.
I made a slight change in your freqz calls so they would use ‘Fs’ correctly, and I use filtfilt rather than filter to do the fil...

7 years ago | 1

| accepted

Answered
How can i get standard deviation in a scatter3 plot
It would be easiest to concatenate your scalar variables into a matrix, then take the standard deviation of the matrix rows: S...

7 years ago | 0

Answered
The function return value 'value' might be unset.
Your function returns the variable ‘value’, however you never assign anything to ‘value’ in your function (at least not that I c...

7 years ago | 0

| accepted

Answered
How can I create a surface plot with 3 independent variables? I dont want to construct using a trisurface plot. File is attached.
Your data are gridded, so you simply need to reshape the vectors appropriately, then plot the resulting matrices: fidi = fopen...

7 years ago | 1

| accepted

Answered
Subscript indices must either be real positive integers or logicals.
In this instance (using the Symbolic Math Toolbox), it will work as you want if you create ‘F’ as a function: F(s) = Cm*t*s/(C...

7 years ago | 1

Answered
Matrix with 64 Rows and 16 Columns
Please see the documentation section on Matrix Indexing (link). You need a second index to address your matrices. What you do ...

7 years ago | 0

Answered
Can i have a matrix with identical rows?
You can, however you will find that it’s not useful. The identical rows are linearly dependent, so the rank of the matrix will ...

7 years ago | 0

Answered
Im trying to find the x value that minimises the y value
Using the ga function is likely overkill for such a small problem. Try this: iv = rand(7,1) [v,fval] = fminsearch(@fuel_us...

7 years ago | 0

| accepted

Answered
How can I change this loop so that it has no errors?
At i=97, ‘e1’ and ‘e2’ become (2x1) vectors rather than scalars as they are for the first 96 iterations. The easiest way to dea...

7 years ago | 0

| accepted

Answered
Import columns of numbers separated by rows of text
One approach to that problem that has worked previously for me is: fidi = fopen('YourFile.txt','rt'); k1 = 1; while ~feof(fi...

7 years ago | 0

Load more