matlab coding for mean value of one row [closed] - matlab

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need matlab coding for measuring mean value of one row in a matrix of 180 by 50 rows and columns. Each time the number of row in a matrix needs to be updated to get mean value of next row (like new_row=1:1:180). Kindly respond as soon as possible

You are looking for mean().
mean(A,2)
This will give you the means of each row of matrix A.
P.S.: If you already save one row in a vector, say new_row, you can simply use:
mean(new_row)

Related

How to make a new matrix based on column values in an old matrix? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am very new to Matlab and coding in general, so I apologize if this is a basic question.
I have a matrix of three columns (data1) where the first column refers to time (s).
I would like to make a new matrix (bout1) consisting of entire rows of the matrix data1 based on the values in the first column (so, for example, in a range from 30 s to 120 s).
I know how to extract the rows based on the row number:
bout1 = data1(361126:391643,:)
but not based on the values in a specific column.
You can use the find function (see here) to find the rows you need, like this:
time = data1(:, 1);
i = find(30 <= time & time <= 120);
bout1 = data1(i, :);

Matlab : Opposite function of "primes" in matlab [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Is there any opposite function of "primes" in matlab?
(Primes : Prime numbers less than or equal to input value)
What if i want to find greater than or equal to input value?
Thank you.
You always have to provide an upper limit. If you wanted prime numbers "greater than or equal to the given value," they would go to infinity.
I would suggest starting with "less than or equal to," provide the function with an upper limit, and then use a conditional to filter out those that are too small.

how to create a signal consisting of a delay of 1000 samples of zeros? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How to write the MATLAB code
to create a signal consisting of a 'delay' of 1000 samples of zeros,
followed by variable which i found in previous part 'sss' of 1000 samples and the message I've created 'msg' ?
so there are three variables 'delay' , 'sss' , and 'msg'
please help. thanks
Concatenate them.
newSignal = [delay sss msg];

loop to add present state with previous state [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to make a loop in order to add the current state with the previous state.
For example:
M=1000;
for i=1:M A=i*(x(i));
This formula will be for M=1 but when M=2 the formula will be like this:
A=(i*(x(i))+((i-1)*(x(i-1)))
and when M=3 the formula will be
A=(i*(x(i))+((i-1)*(x(i-1)))+((i-2)*(x(i-2))
and so on till reach the maximum length of M which is 1000.
Your question is quite vague but it sounds like you just want a cumulative sum of the i*x(i) series:
i = 1:M;
s = i.*x(i);
cumsum(s);

How can I apply a ring-shaped median filter to an image in matlab? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
The default matlab function medfilt2 uses a rectangular mask.
Thanks guys
you can use ordfilt2 .
For example, if your "ring" is just defined by:
ring= fspecial('gaussian',21,1)
ring = ring>eps & ring<1e-9
then:
order=sum(ring(:))/2;
B = ordfilt2(A,order,ring);
replaces each element in A by the order-th element in the sorted set of neighbors specified by the nonzero elements in the ring domain.
Here I chose 'order' to be half the total # of the pixels in the ring.