Answered
How to divide a signal spectrum?
One option is to use the <https://www.mathworks.com/help/matlab/ref/reshape.html *|rehsape|*> (link) function: V = 0:29; ...

9 years ago | 0

| accepted

Answered
why simulink gives wrong answer of trigonometery
It seems that you are seeing floating-point approximation error. See <http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0...

9 years ago | 0

| accepted

Answered
replace not selected value by zero
This works: x=[1 2 3 4 5 6 7 8 9 10]; ToKeep = [1 3 5]; idx = ismember(x, ToKeep); Result = x .* idx R...

9 years ago | 1

| accepted

Answered
I need to remove randi from for loop
The code you posted does exactly what you describe. Try this instead of the loop if you simply want something different: ...

9 years ago | 0

Answered
Why answer is in different ?
It arises from the way MATLAB decides what constitute the elements of an array. The square brackets tell MATLAB that the conten...

9 years ago | 1

| accepted

Answered
How to name each row and column of a Matrix
The only way I can think of to do this is to use a <https://www.mathworks.com/help/matlab/ref/table.html *|table|*> (link). See...

9 years ago | 0

Answered
How to define variable sets for changing value of i ?
I still do not understand what you want to do. However, if you want to _preallocate_ them, that is easy. Delete these line...

9 years ago | 0

Answered
How to get the Couette Flow?
I do not understand the problem, since your code seems to work. If the movie is not showing correctly *|10|* times, it could be...

9 years ago | 0

Answered
program that returns random letter
Start here: UCL = 'A':'Z'; % Vector Of Uppercase Letters then choose one!

9 years ago | 1

Answered
convert binary array to different set array
Try this: C3 = ['111' '010' '101' '111' '110' '110' '101']; C...

9 years ago | 0

Answered
How to add a matrix into a specific part of a matrix?
It is difficult to provide help without giving away the solution. I have a working solution. I would prefer to see your soluti...

9 years ago | 1

| accepted

Answered
Trouble passing a vector as the input for a function
There are much more straightforward ways to do what you want. However, to do it in a loop, you need to index the individual ele...

9 years ago | 0

| accepted

Answered
Sketching function for V(t)
See the documentation on <http://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html *Anonymous Functions*> (link...

9 years ago | 0

Answered
How to convert fft results to frequency?
You have to create the frequency vector yourself, however that is not difficult. See the documentation on <https://www.math...

9 years ago | 0

| accepted

Answered
Function contain the term I dont understand
The *|‘<=0’|* creates a _logical vector_, so that if *|‘(x-xshift)’|* is less than zero, the value for that sub-expression is *|...

9 years ago | 0

Answered
How to convert a '40*1 double' variable into '40*1 cell' variable?
I would use the <https://www.mathworks.com/help/matlab/ref/num2cell.html *|num2cell|*> (link) function.

9 years ago | 0

| accepted

Answered
vectors must be the same length
You probably want to use *|‘xa’|* rather than *|‘x’|* in your *|‘ya’|* calculation: ya = 4.15+(1.73.*(xa-3.15))+(0.1.*(xa-...

9 years ago | 0

Answered
Matlab code generate figure but does'nt create sound?
You have two problems: # you have to create *|‘Signal’|* as a *_column_* vector, not as a matrix, # you need to multiply (...

9 years ago | 0

| accepted

Answered
Is there a way to show gain has been added to a signal?
I would take the <https://www.mathworks.com/help/releases/R2015a/matlab/ref/fft.html *|fft|*> (link) of both, express them both ...

9 years ago | 1

| accepted

Answered
single legend entry for all lines of plotted array?
I cannot run your code. Since you have *|'DisplayName'|* defined in every *|plot|* call: p(1) = plot(1:nv,wspec.spec(~gou...

9 years ago | 0

| accepted

Answered
To roll a dice simulator
One way to approach this (and the one that seems most compatible with your *_homework assignment_*) is to use a *|while|* loop w...

9 years ago | 0

| accepted

Answered
I have a scatterplot where the points are colored by group number. How do I add a legend with the group color attached?
If you have the Statistics and Machine Learning Toolbox, it is probably easier to use the <https://www.mathworks.com/help/stats/...

9 years ago | 1

| accepted

Answered
Getting multiple outputs using lqr function
There is no reason to avoid explicit loops. Many MATLAB functions have very efficient implicit loops, so they are preferred ove...

9 years ago | 0

Answered
Help with HW question regarding Sine waves
It looks correct to me.

9 years ago | 0

Answered
How to make a for loop jump multiple iterations, if a condition happens?
*_‘But in the next iteration the r is always the next number, and not r+6.’_* You cannot change the index variable within a...

9 years ago | 0

| accepted

Answered
How to solve integral of vector
You have to specify *|‘'ArrayValued',true’|* in the *|integral|* call. To integrate over a vector *|‘t’|*, use the *|arrayfun|*...

9 years ago | 0

| accepted

Answered
Problem with Interp1
If you want to find the *|‘x’|*-values where *|‘y’|* equals *|‘thresh’|*, you need to reverse the order of *|‘x’|* and *|‘y’|* i...

9 years ago | 0

| accepted

Answered
Does anyone know how to fix this?
See if using *|image|* rather than *|pcolor|* works. The *|pcolor|* function reduces each dimension by *|1|*, if I remember cor...

9 years ago | 0

| accepted

Answered
how to name xbars with the names on number sequence?
That looks as though it should work. If it is not working, add *|'XTick'|* to specify the locations where the labels should app...

9 years ago | 1

| accepted

Answered
How to ignore NaN values in the CORR Function?
Use the *|'rows','complete'|* name-value pair to ignore rows with *|NaN|* values: A = [1;2;3;4] B = [3;5;7;NaN]; ...

9 years ago | 23

Load more