Respondida
How to merge matrices generated from a for loop into one matrix.
E.g., as a matrix of columns: solutionV = zeros(___,numel(k)); % <-- fill this in to pre-allocate : solutionV(...

más de 9 años hace | 0

Respondida
What is wrong with my code? Cycle while help
You need to break out of the loop when you hit the bottom corner. Also, you need to add in code that updates m and/or n as you ...

más de 9 años hace | 1

| aceptada

Respondida
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 ...

más de 9 años hace | 2

| aceptada

Respondida
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 ...

más de 9 años hace | 2

Respondida
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 ) ...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 0

Respondida
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 ...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 0

Respondida
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 = ...

más de 9 años hace | 1

| aceptada

Respondida
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(...

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 1

| aceptada

Respondida
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 ...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 1

Respondida
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...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 1

| aceptada

Respondida
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 ...

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 2

Respondida
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...

más de 9 años hace | 0

| aceptada

Respondida
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; ...

más de 9 años hace | 3

| aceptada

Respondida
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); ...

más de 9 años hace | 0

| aceptada

Respondida
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) ...

más de 9 años hace | 1

Cargar más