回答済み

Matrix column subtraction problem

C = zeros(5,2*3); for p = 1:2 for q = 1:3 C(:,3*p+q-3) = A(:,p)-B(:,q); end end Or this: C = re...

Matrix column subtraction problem

C = zeros(5,2*3); for p = 1:2 for q = 1:3 C(:,3*p+q-3) = A(:,p)-B(:,q); end end Or this: C = re...

3年以上 前 | 0

| 採用済み

回答済み

Generate N observations from a uniform distribution on [0,1] and compare it to a threshold

Here's another way. Let there be N1 trues and N0 falses. x = [repmat(true,1,N1),repmat(false,1,N0)]; x = x(randperm(N1+...

Generate N observations from a uniform distribution on [0,1] and compare it to a threshold

Here's another way. Let there be N1 trues and N0 falses. x = [repmat(true,1,N1),repmat(false,1,N0)]; x = x(randperm(N1+...

3年以上 前 | 1

| 採用済み

回答済み

How to find minimal distance between elements?

Let your vector be called v. Then do this: d = min(diff(sort(v))); This finds the minimum distance between any two elem...

How to find minimal distance between elements?

Let your vector be called v. Then do this: d = min(diff(sort(v))); This finds the minimum distance between any two elem...

3年以上 前 | 3

| 採用済み

回答済み

please check the following code in shown the error

It looks to me as though the line H(t) = rand(M(t),K) + i*rand(M(t),K); is in error. On the first trip through that for...

please check the following code in shown the error

It looks to me as though the line H(t) = rand(M(t),K) + i*rand(M(t),K); is in error. On the first trip through that for...

3年以上 前 | 0

回答済み

key generation and inversing

Your code first puts the successive integers from 1 to n*m in the vector 'invKey'. Then it subjects them to a randomly determin...

key generation and inversing

Your code first puts the successive integers from 1 to n*m in the vector 'invKey'. Then it subjects them to a randomly determin...

3年以上 前 | 1

| 採用済み

回答済み

How can i generate continuous random numbers with multiple limit zones in matlab? For ex:i want numbers btw 50 and 150 but it should not contain numbers from 110 to 120

I interpret your words "continuous random numbers" to mean all real numbers within the given limits, not just integers. Suppose...

How can i generate continuous random numbers with multiple limit zones in matlab? For ex:i want numbers btw 50 and 150 but it should not contain numbers from 110 to 120

I interpret your words "continuous random numbers" to mean all real numbers within the given limits, not just integers. Suppose...

3年以上 前 | 1

| 採用済み

回答済み

Find the max value in a kernal

Let M be your matrix. Let R be a vector of the matrix's row subscripts of your kernel, and let C be a vector of corresponding c...

Find the max value in a kernal

Let M be your matrix. Let R be a vector of the matrix's row subscripts of your kernel, and let C be a vector of corresponding c...

3年以上 前 | 0

回答済み

3 dimentions matrix Creation

I think you asking how to do this: A = repmat(A,1,1,100);

3 dimentions matrix Creation

I think you asking how to do this: A = repmat(A,1,1,100);

3年以上 前 | 0

| 採用済み

回答済み

Select nearest value on a vector for a given value

I notice that your vector 'Value' has ascending elements. If we can assume that, the following can be used: s = -8; % Or...

Select nearest value on a vector for a given value

I notice that your vector 'Value' has ascending elements. If we can assume that, the following can be used: s = -8; % Or...

3年以上 前 | 0

| 採用済み

回答済み

Displaying complex roots of quadratic equation

On that 'else' part you need to find the two values real(x1) and imag(x1) as well as these two for x2. Then provide a display o...

Displaying complex roots of quadratic equation

On that 'else' part you need to find the two values real(x1) and imag(x1) as well as these two for x2. Then provide a display o...

3年以上 前 | 0

回答済み

A(:) = B, the number of elements in A and B must be the same. error, what am I doing wrong?

The problem lies with the lines x(k) = x(k-1)+dxdt*Ts; y(k) = y(k-1)+d2xdt2*Ts; z(k) = z(k-1)+d3xdt3*Ts; On the...

A(:) = B, the number of elements in A and B must be the same. error, what am I doing wrong?

The problem lies with the lines x(k) = x(k-1)+dxdt*Ts; y(k) = y(k-1)+d2xdt2*Ts; z(k) = z(k-1)+d3xdt3*Ts; On the...

3年以上 前 | 0

回答済み

How to make 3 random numbers that sum to 1

If you want your results statistically uniform area-wise, you can use the 'randfixedsum' function in the File Exchange at: <h...

How to make 3 random numbers that sum to 1

If you want your results statistically uniform area-wise, you can use the 'randfixedsum' function in the File Exchange at: <h...

3年以上 前 | 1

回答済み

Finding the sum of a series without symsum

You don't need 'symsum' to evaluate that series. It's easy to see that its sum is com_cos = cos(x_val)-1 just by inspec...

Finding the sum of a series without symsum

You don't need 'symsum' to evaluate that series. It's easy to see that its sum is com_cos = cos(x_val)-1 just by inspec...

3年以上 前 | 1

| 採用済み

回答済み

Different result by hand-differentiaion vs MATLAB diff() function.

Your "hand-differentiation" is not correct! The 'diff' answer is correct but can be simplified to an equivalent -2/(y+1)^3. (...

Different result by hand-differentiaion vs MATLAB diff() function.

Your "hand-differentiation" is not correct! The 'diff' answer is correct but can be simplified to an equivalent -2/(y+1)^3. (...

3年以上 前 | 0

| 採用済み

回答済み

plot plane through set of 3d point

If X, Y, and Z are vectors of the x,y,z coordinates of your points, do this: dX = X-mean(X); dY = Y-mean(Y); dZ = Z...

plot plane through set of 3d point

If X, Y, and Z are vectors of the x,y,z coordinates of your points, do this: dX = X-mean(X); dY = Y-mean(Y); dZ = Z...

3年以上 前 | 0

回答済み

How to create a specific vector c that has two variables x and y ?

Assume your xi's and yi's are given by a couple of column vectors, x and y of the same length. n = length(x); A = [x.^(n...

How to create a specific vector c that has two variables x and y ?

Assume your xi's and yi's are given by a couple of column vectors, x and y of the same length. n = length(x); A = [x.^(n...

3年以上 前 | 0

回答済み

How to solve a system of equations?

To solve these you would have to satisfy both x(1)^2 + (x(2)+10)^2 + x(3)^2 = x(1)^2 + (x(2)-10)^2 + x(3)^2 x(1)^2 + (...

How to solve a system of equations?

To solve these you would have to satisfy both x(1)^2 + (x(2)+10)^2 + x(3)^2 = x(1)^2 + (x(2)-10)^2 + x(3)^2 x(1)^2 + (...

3年以上 前 | 1

回答済み

Hi!!! I have a N-dimensional matrix. I want to convert into vector by discarding the decimal values less the 0. Please provide matlab code for this. Thank you

Let M be your matrix. M = M(M>=0);

Hi!!! I have a N-dimensional matrix. I want to convert into vector by discarding the decimal values less the 0. Please provide matlab code for this. Thank you

Let M be your matrix. M = M(M>=0);

3年以上 前 | 0

| 採用済み

回答済み

kindly help in debugging the following code for optimization

Matlab's error message is quite true - you have not defined P. Evidently you intended to have: P = [P1 P2 P3 P4 P5]; bu...

kindly help in debugging the following code for optimization

Matlab's error message is quite true - you have not defined P. Evidently you intended to have: P = [P1 P2 P3 P4 P5]; bu...

3年以上 前 | 0

| 採用済み

回答済み

Evaluate a Polynomial without polyval

Note that you can avoid the necessity of computing powers of x in the following. It works even if x is an array. It should sav...

Evaluate a Polynomial without polyval

Note that you can avoid the necessity of computing powers of x in the following. It works even if x is an array. It should sav...

3年以上 前 | 0

回答済み

Custom Uniform Random Distribution

If you want to obtain a density distribution proportional to 1/sqrt(x) for x in some finite interval [a,b], you can proceed as f...

Custom Uniform Random Distribution

If you want to obtain a density distribution proportional to 1/sqrt(x) for x in some finite interval [a,b], you can proceed as f...

3年以上 前 | 0

回答済み

how to generate combination through specific matrix dimension?

As James has stated, your question is not clear. I'm going to make a very wild guess as to your meaning. If it is wrong, as is...

how to generate combination through specific matrix dimension?

As James has stated, your question is not clear. I'm going to make a very wild guess as to your meaning. If it is wrong, as is...

3年以上 前 | 0

回答済み

I want to plot F(x) and G(x) in same graph for x=(-10,10) how can I do this?

x = linspace(-10,10); f = 5*x.^2+9*x+2; G = 3*x+12; plot(x,f,'r-',x,G,'g-')

I want to plot F(x) and G(x) in same graph for x=(-10,10) how can I do this?

x = linspace(-10,10); f = 5*x.^2+9*x+2; G = 3*x+12; plot(x,f,'r-',x,G,'g-')

3年以上 前 | 0

回答済み

How do I plot this?

I assume you had in mind that x is given in degrees. You will get some discontinuities with these: x1 = 1:.1:20; y1 = 2*s...

How do I plot this?

I assume you had in mind that x is given in degrees. You will get some discontinuities with these: x1 = 1:.1:20; y1 = 2*s...

3年以上 前 | 0

回答済み

Undefined function or variable 'r', but I am confident I defined it

In your code you set xrold equal to xr and compute ea: ea=abs((xr-xrold)/xr)*100; which not surprisingly gives ea a zero...

Undefined function or variable 'r', but I am confident I defined it

In your code you set xrold equal to xr and compute ea: ea=abs((xr-xrold)/xr)*100; which not surprisingly gives ea a zero...

3年以上 前 | 0

回答済み

How can I fix the error, or what does it mean "Subscript indices must either be real positive integers or logicals."?

The error refers to the line Density(n,N) = ... because both n and N are being as indices in 'Density' but neither are ...

How can I fix the error, or what does it mean "Subscript indices must either be real positive integers or logicals."?

The error refers to the line Density(n,N) = ... because both n and N are being as indices in 'Density' but neither are ...

3年以上 前 | 0

回答済み

Generate pair of random numbers with respect to a sum constraint?

(Corrected) Assuming you restrict x and y to non-negative values, the set of x and y values for which x+y<=1 would be a triangu...

Generate pair of random numbers with respect to a sum constraint?

(Corrected) Assuming you restrict x and y to non-negative values, the set of x and y values for which x+y<=1 would be a triangu...

3年以上 前 | 1

| 採用済み

回答済み

How to find a velocity when you have time and position values in an array?

Let x and y be row vectors of the same length where x gives successive values of the independent variable and y the correspondin...

How to find a velocity when you have time and position values in an array?

Let x and y be row vectors of the same length where x gives successive values of the independent variable and y the correspondin...

3年以上 前 | 0

回答済み

dr/dt* ln(a*r*dr/dt)=b/r^7 how to solve this equation

Here is how I would approach your problem. First we write a*r*dr/dt*log(a*r*dr/dt) = a*b/r^6 Now define w: w = log...

dr/dt* ln(a*r*dr/dt)=b/r^7 how to solve this equation

Here is how I would approach your problem. First we write a*r*dr/dt*log(a*r*dr/dt) = a*b/r^6 Now define w: w = log...

3年以上 前 | 0

回答済み

According to SVD technique A=U*S*V'. But when I apply SVD to my image, I am not able to retrieve my original image. Is that because S matrix is not taking the all the eigen values? Eventhough, I had to get a partially correct image?

You've left off the transpose operator at the last step: ap*v'; It's a very small character, but it's all-important! ...

According to SVD technique A=U*S*V'. But when I apply SVD to my image, I am not able to retrieve my original image. Is that because S matrix is not taking the all the eigen values? Eventhough, I had to get a partially correct image?

You've left off the transpose operator at the last step: ap*v'; It's a very small character, but it's all-important! ...

3年以上 前 | 0

| 採用済み