Answered
The following three lines could be used to create a plot of the Sine function: >> a = 3; >> b = 0: pi/a: 2*pi; >> plot(b,sin(b))
If you split the commands, you might figure it out yourself a = 3 b = 0:pi/a:2*pi y = sin(b) plot(b,y,'o-') % conn...

12 years ago | 0

Answered
Splitting a matrix by even and odd numbers
use rem to determine which list of numbers is even or odd X = [1 3 4 2 5 4 2] % hint X is the first column of your matrix ...

12 years ago | 2

| accepted

Answered
How can I delete certain rows of a matrix based on specific column values?
This is a job for logical indexing! Note that you do not need to loop over all the lines at all Assume A is your matrix. Here...

12 years ago | 13

| accepted

Answered
while converting any number to string with num2str() floating numbers aren't preserved.
If you carefully read the help of num2str, you will see that you can use a second argument … <http://www.mathworks.nl/help/ma...

12 years ago | 0

| accepted

Answered
Reshaping (M,N)-matrix to (M,1)-matrix
Another trick using strings: A = [1 2 3 ; 10 11 12 ; 90 0 99] B = str2num(sprintf([repmat('%d',1,size(A,2)) ' '],A.'...

12 years ago | 1

Answered
how to compare two cells and fetch the values ?
Use cell array of strings, so you can use all the available set functions: y = {'A','B','F'} x = {'A','BBB','C','D','E',...

12 years ago | 0

Answered
error using subplot,index exceed numbers of subplots
A general solution that loops over the values using a separate index: x=1:1:10 value = 2:2:8 N = numel(value) fo...

12 years ago | 0

Answered
how to compare the value of a pixel with all other pixel?
You question is a little unclear. But, see help unique M = ceil(10*rand(40,30)) % pixel image uM = unique(M) ; ...

12 years ago | 0

Answered
Arranging two arrays in ascending order.
Use the second output of sort: A = magic(3) % unsorted values B = reshape(1:numel(A),size(A)) [sortedA,ix] = sor...

12 years ago | 0

Answered
How to construct this vector without loop?
Here is flexible version *not* using cell2mat: n = 4 ; % user specified V = 3 ; % as in the example -> [1:V 1:2*V ... ...

12 years ago | 0

| accepted

Answered
Adding three cells element wise using cellfun
D = cell(size(A)) ; for k=1:numel(A), D{k} = A{k}+B{k}+C{k} ; end

12 years ago | 0

Answered
how to create a vector of consecutive numbers that skip over certain elements
Another approach: K=[0; 0; 1; 0; 0; 1; 1; 0; 0; 1] R = cumsum(K==0) R(K==1) = 0

12 years ago | 1

| accepted

Answered
How to randomly repeat an array elements?
Here is an approach: P = [1 -1 j -j] N = 16 ; ix = ceil(numel(P)*rand(1,N)) % random indices into P Y = P(ix)...

12 years ago | 2

| accepted

Answered
Can someone help implement the perfect shuffle function?
x = 'ABCDEFGHIJKL' m = 3 % the following line pre-allocates an output to store things in, makes things faster! y...

12 years ago | 0

Answered
How to write this expression in matlab ? Boolean logic
you really should take a look at the logical operators & and | and ~ <http://www.mathworks.nl/help/matlab/ref/logicaloperatorse...

12 years ago | 1

Answered
how can make a matrix from many vectors?
... and if the vectors are not of the same lengths, you can use <http://www.mathworks.com/matlabcentral/fileexchange/22909-padca...

12 years ago | 1

Answered
How to enter multiple values for one input prompt
INPUTDLG accepts multiple inputs <http://www.mathworks.nl/help/matlab/ref/inputdlg.html>

12 years ago | 2

| accepted

Answered
intersect(A,B) returns the data with no repetitions
I think you are looking for the second output of SORT A = [ 4 1 1 2 3] [B, ix] = sort(A, 'ascend') Now, B equals A(ix...

12 years ago | 1

| accepted

Answered
concatenate mutiple tables by repetative process
How are these tables stored in your workspace? Do they all have an individual name (like Table1, MyOtherTable, B, DDDDD, ...)? ...

12 years ago | 0

| accepted

Answered
intersect(A,B) returns the data with no repetitions
I do not get it. Will *same* not always be exactly *B*?

12 years ago | 0

Answered
I think my program is complete.. What happen to this line? u(i)=sin(pi*x(i)); ??
it is still there ... Note that you can make use of the fact that matlab is all about handling matrices (i.e., lists of numbe...

12 years ago | 1

Answered
Generate random binary matrix
Should all possibilities of such a matrix be equally likely? Then it might be very quite tricky. Here's a brute force approac...

12 years ago | 1

Answered
problem using counter in a for loop
There are at least two issues with this code: function x = triangle(n) i = 1; for i:n-1 x(i) = i+x(i+1); % (1) BO...

12 years ago | 1

| accepted

Answered
Shadowing built-in functions
From the release notes of ML2015a: - New built-in function xbuffer. So check all your miles and change the variable xbuffer i...

12 years ago | 0

Answered
why is a blank ignored in strcat
This used to be my workaround for the way strcat handles spaces: strrep(strcat('AAA', '#SPACE#', 'BBB'),'#SPACE#',' ')

12 years ago | 0

Answered
How to write this expression in matlab ? p ^ q ^ r
p^q^r p = true ; q = true ; r = false ; tf = p && q && r help and

12 years ago | 0

Answered
How do i cut a string after an amount of values or a delimiter
Something along these lines, perhaps (untested!): % data: str = '1 2 3 4 5 6; 7 8 9 10 11 12; 13 14 15 16 17 18' TextT...

12 years ago | 0

Load more