Respondida
If I select an element in a matrix, say MAT(2,2), how to find how many elements of the same value of MAT(2,2) in the matrix are "connected" to it.
You need bwconncomp <https://it.mathworks.com/help/images/ref/bwconncomp.html> For example: Mat=[1 2 3 4 2;2 2 2 2 0;...

más de 7 años hace | 2

Respondida
how to change or compliment a particular bit in the binary string?
Here it is a=50; b=dec2bin(a) pos = 4; b(pos) = char(97-double(b(pos)))

más de 7 años hace | 1

Respondida
string to number conversion with mixed values
str1 = 'index_N=10' str2 = 'index_M=5' sub1 = str1(7:end) sub2 = str(7:end)

más de 7 años hace | 0

Respondida
How do i adjust the spacing between the slices of my stacked images?
First, most probably you don't want to stack them in the 4-th dimension as you wrote rgb4D = cat(4, IA, IB, IC, ID); Bec...

más de 7 años hace | 0

Respondida
3D grouped bar graph
I think the only way is to group data into one matrix (bar2 groups data row-wise) figure(1) bar3([y1,y2],'grouped')

más de 7 años hace | 0

Respondida
Randomly scramble letters in a single word
No need of while. If you want to permute word letters with forced use of a loop, extract one-by-one the letters from word withou...

más de 7 años hace | 1

Respondida
How to find unique elements in a vector without using unique or find?
Use an histogram based approach (works only for positive integers) %get M random numbers from 1 to N M=10; N=25; ...

más de 7 años hace | 0

| aceptada

Respondida
How to mirror matrix on the diagonal?
In the case described before it is: A=[1 2 3;4 5 6;7 8 9] rot90(A,2)' which gives: A= 1 2 3 4 5 6 ...

más de 7 años hace | 4

Respondida
Can waitforbuttonpress function be used with switch cases..?
Output of waitfrobuttonpress is not a string, is number: for i=1:10 keydown = waitforbuttonpress; switch k...

más de 7 años hace | 1

| aceptada

Respondida
How to load a .dat file?
<https://it.mathworks.com/matlabcentral/answers/79885-reading-dat-files-into-matlab>

más de 7 años hace | 0

Respondida
How can I write both number and text to a file?
Look here: <https://it.mathworks.com/help/matlab/ref/fprintf.html> Here it is: x = 'BEGIN 0.00 0,0 0.5,1 1,1.5 1.5,1....

más de 7 años hace | 0

Respondida
Find entire rows in a matrix where a column value meets a certain condition
Assume your 50000x4 matrix is A, this will remove all the rows such having 4th element = 101300: A(A(:,4)~=101300,:)=[];

más de 7 años hace | 0

Respondida
How to I overlap two images?
Here it is img = zeros(256,256); img(:, [1:6:end, 2:6:end, 3:6:end]) = 1; imshow(img), axis on; %build RGB image...

más de 7 años hace | 1

| aceptada

Respondida
Creating a matrix with binomial distribution in elements.
Check for "binornd" function in Matlab docs

más de 7 años hace | 0

Respondida
Convert 3D matrix to 2D matrix.
I try to guess from your question: %random 3D array A=rand(5,6,7); %extract a 2D matrix from first dimension of A ...

más de 7 años hace | 0

| aceptada

Respondida
Sort 3d matrix according to another 3d matrix
According to Walter's comment, the previous solution was wrong. Here is a way to sort B given the sorted A along the 3-rd dimens...

más de 7 años hace | 0

| aceptada

Respondida
Exporting Figures in matlab
I don't think export_fig allows you to set height and width. But, consider using -m<val> - option where val indicates the ...

más de 7 años hace | 0

Respondida
Can someone explain why I'm getting 0 as answer for the following integral?
This is a case where quadrature formulas fail.. Indeed, by computing the (very simple) integral manually, one gets integ_...

más de 7 años hace | 0

Respondida
Error when running certain function
Type the command ver in the command line, and check in the list if Financial Toolbox is there. If not, you need to inst...

más de 7 años hace | 0

Respondida
Graphs Not Showing Up
You just see the last two ('3' and '4') because the values are the same, so curve are superimposed and you just see the last one...

más de 7 años hace | 0

Respondida
How to reshape an matrix made from an input turned into a double value?
Your code only works for 4-characters long strings because you are reshaping them to 2x2 matrix.

más de 7 años hace | 0

Respondida
How to plot the relationship between two unknown values as those values change?
For every Y~=T, the equation above is true for X=WZ/(Y-T)...

más de 7 años hace | 0

| aceptada

Respondida
random data generation using mean and identity matrix
Just transpose the solution: MU=zeros(1,10); SIGMA=eye(10); xTrain = mvnrnd(MU,SIGMA,1000)';

más de 7 años hace | 0

| aceptada

Respondida
Compute a new vector dependent on two others and a random probability
By doing x==0.2 | y==0.2 you are testing that ALL theelements of x or y equal 0.2. Is that really what you want?

más de 7 años hace | 0

Respondida
What is the logic behind fzero and fsolve which make fsolve's speed faster than fzero?
The functions fsolve and fzero are not meant to solve the same problem. Specifically: # fzero: It finds the root of a functio...

más de 7 años hace | 6

| aceptada

Respondida
questions about solving a linear equations ( \ vs pinv vs least-square)
Your matrix X has full rank, so the difference between the two methods shouldn't be so high. Running it on my pc I indeed obtain...

más de 7 años hace | 0

Respondida
How to plot semilog y graphic in Matlab?
The matlab function semilogy() is what you need: <https://it.mathworks.com/help/matlab/ref/semilogy.html?searchHighlight=semi...

más de 7 años hace | 2

| aceptada

Respondida
sort X and Y columns according to a repeated string in a 3rd column and scatter plot
Get the "subject" column in one array containing data of all people, as follows: allsubjects = data(:).subject

más de 7 años hace | 0

Respondida
[V,D]=eig(S1,S2) ?
They are not captured by the syntax of eig(A,B). Let me explain you why: The call [V,D] = eig(A,B) returns diagonal ...

más de 7 años hace | 0

Respondida
a matlab code of getting a value uniformly at random from a the set {-1,1}
If you look for a real number in the interval [-1,1], here is it n = 2*rand-1 If you look for an integer either 1 or -1,...

más de 7 años hace | 2

Cargar más