Answered
How to find which column in a matrix/array has a nonzero value?
column_number = find(x(6,:)); % <-- search the 6th row only However, why didn't the "col" variable in your attempt work ...

9 years ago | 2

| accepted

Answered
Hi evry one . Howe can i plot these ?
E.g., fixing up one operator in your equation x = -10:0.01:10; Y = (x.^2-4*x+3)./(x.^2-6*x+8); % <-- You needed to use ...

9 years ago | 2

Answered
How to only perform the upper triangular part of matrix operations?
If you can't change the looping, then maybe just insert an if-test: if( indi <= indj ) ...

9 years ago | 0

| accepted

Answered
How to call MATLAB function from Fortran 77 subroutine
See the External Interfaces API section of the doc. The Engine would be one option. Or rewriting your Fortran as a mex routine...

9 years ago | 0

Answered
while loop dose not update the variable :(
To test if vectors are not equal to each other in an if-test, using the element-wise operator ~= will produce a vector result an...

9 years ago | 0

Answered
How to generate lower triangle in a matrix where elements are the inverse of the upper traingle and diagonal is one
E.g., >> M = [0 7 9 8; 0 0 8 6; 0 0 0 4; 0 0 0 0] M = 0 7 9 8 ...

9 years ago | 0

| accepted

Answered
how can i find the error in my function please
Your current code simply returns the input as a column vector in the same order ... it does nothing to "flip" the actual element...

9 years ago | 0

Answered
Write a code using any programming language to generate 100 random variable of Rayleigh distribution.
See this link: https://www.mathworks.com/matlabcentral/answers/285394-how-to-generate-rayleigh-distributed-random-variable-wi...

9 years ago | 0

Answered
Error using * Inner matrix dimensions must agree? It also shows an error for Y, but I can't figure out what it is?
In addition to replacing appropriate * with .* and / with ./ you have an error with a t^.2 instead of a t.^2 w = 3; t = ...

9 years ago | 1

| accepted

Answered
Error using ' Transpose on ND array is not defined. Use PERMUTE instead.
Try changing this line fwrite(f, image', 'uint8'); to this (transposes the first two dimensions) fwrite(f, permute(...

9 years ago | 1

| accepted

Answered
Is it possible to get access to variables within function handles?
The only way I would be aware of would be a mex hack. E.g., c = 3; f = @(x) x + c; The "c" inside of the function ha...

9 years ago | 0

Answered
How to define a function with mexCallMatlab
I am still not entirely sure this is what you want, but here goes ... // Takes 6-element x, passes it to MATLAB function fu...

9 years ago | 1

| accepted

Answered
How to write y(n)=y(n-1)+x(n) in a way to store all values of y from n=1 to n?
There are vectorized ways to do this, but using your formula directly: y = zeros(size(x)); y(1) = something; % <-- you ...

9 years ago | 0

| accepted

Answered
Error using * Inner matrix dimensions must agree.
Maybe you need to do element-wise multiply for that calculation using the .* operator (with the dot in the front) instead of the...

9 years ago | 0

| accepted

Answered
Calculate covariance of a matrix without using cov(matrix)
Another way: MM = bsxfun(@minus,M,mean(M)); covM = MM'*MM/(size(M,1)-1);

9 years ago | 0

Answered
I have to use {} in my for loop, but now I can't multiply...
Treat the x"sub n" in the screenshot as x(n) in MATLAB. I.e., the n'th element of a vector called "x". So x"sub 1" in the sc...

9 years ago | 1

Answered
How to Save the outputs of my for loop?
rand(i) is going to create a different sized matrix for each iteration, namely a square matrix of size i x i. That's why you ar...

9 years ago | 0

| accepted

Answered
What is the best way to keep two variables synchronized?
_"... any pointer-like solutions I've seen are hacks using functions or classes derived from handles ..."_ This is really th...

9 years ago | 0

| accepted

Answered
For loop on a 3D matrix
Does this do what you want? for I = 40:60 my3Dslice = my3Darray(:,:,I); %Algorithms code end

9 years ago | 0

| accepted

Answered
What does this section of code do?
It looks like: i & j are generated as a random point on the board. dx and dy are generated as a random direction (they are...

9 years ago | 1

| accepted

Answered
Creating multiple inputs depending on conditions
Yes, there is a way, but it is a bad idea to do so. Dynamically naming variables with trailing numbers like that makes it very ...

9 years ago | 1

| accepted

Answered
Markov chain with two states using MATLAB
Assuming you want to recover the original 2x2 transition matrix from only the steady state probabilities, this is not uniquely p...

9 years ago | 0

| accepted

Answered
Problem to Threshold a Matrix
Using your small example: >> x = 2; >> y = 2; >> matrix = [ 85 99 21; 54 54 86; 57 12 13] matrix = 85 99...

9 years ago | 2

Answered
trying to plot x(n) = 3cos((2*pi*3*n)/25)
E.g., n = 0:0.01:10; x = 3*cos((2*pi*3*n)/25); plot(n,x) grid on xlabel('n') ylabel('x') title('x = 3*cos...

9 years ago | 0

| accepted

Answered
Multidimensional matrix multiplication with mex
Your basic problem is a misunderstanding of how pointers work in C. Take your z variable for instance: double *z; ...

9 years ago | 3

| accepted

Answered
How to VECTORIZE this code and then convert it into a GPU code ?
Try this: x = I(:,:,2)<120 | I(:,:,1)>155 | I(:,:,3)>160; gsc = 0.2989*I(:,:,1) + 0.5870*I(:,:,2) + 0.1140*I(:,:,3); ...

9 years ago | 0

| accepted

Answered
Need help with homework
You could use a "switch" statement along with the "upper" function to handle case. E.g., an outline: switch upper(order) ...

9 years ago | 1

Answered
How do I search through a tall array element by element?
tall arrays are not "in memory". As such, they cannot be used for controlling "if" and "while" statements since their values (a...

9 years ago | 0

Answered
Could anyone give an idea to write code to solve below problem
You could create a function file and put your loop code inside that file which takes a guess as an input (for Tc(1)) and returns...

9 years ago | 0

| accepted

Answered
2nd Order ODE with RK4 hard code (w/o) built-in Matlab fuctions
You've got your step sizing messed up a bit. Suggest the following changes: % h = 1/n; %time grid % t = linspace(0,10,r...

9 years ago | 0

Load more