Respondida
how can i get a square wave in matlab ?
Something like this? t = linspace(0,20,1000) ; T = 3 ; x = sign(sin(2*pi*(1/T)*t)) ; plot(t,x,'b-')

más de 10 años hace | 1

| aceptada

Respondida
Is there instruction (go to) in MATLAB and if there is no such instruction Is there a instruction similar to it?
No, there is not. Using GOTO is usually ill-advised because it quickly leads to unreadable code. In all cases, the workflow that...

más de 10 años hace | 1

| aceptada

Respondida
when the program is running, is not entering in the loop
Apparently B is larger then 0 ... Did you check?

más de 10 años hace | 0

Respondida
Find one array into another
for integer values you can (often) use the *strfind* trick A = [1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0] B = [1 1 0] idx st...

más de 10 años hace | 0

Respondida
How to break a for loop but then continue with the rest of code
Use break for k=1:100, if rand < 0.2 disp('Break out of for loop') break end end ...

más de 10 años hace | 0

| aceptada

Respondida
Is it possible to connect the points from 2 data sets in a scatter plot with lines?
Something like this? % data x = 1:5 y1 = [1 3 2 4 6] y2 = [2 5 3 2 4] % engine xx = repmat(x(:),1,3)...

más de 10 años hace | 0

| aceptada

Respondida
What does this instruction returns.
Apparently, the function rgb2hsv can return three output arguments. This line of code *explicitly* ignores the last two. A simil...

más de 10 años hace | 0

Respondida
How to set an axes title within the constructor?
You have to pass a handle to a title to the Title property of the axes: ax = axes('Title',title('Fubar'))

más de 10 años hace | 0

Respondida
how can find a point from an array where the points it follows start to decrease
A decrease is where an element is smaller than the element before it. A = [1 2 3 4 3 2 1] changeInA = diff(A) isDecre...

más de 10 años hace | 0

Respondida
replace first elements from 1 col to numbers
help strrep help str2double

más de 10 años hace | 0

Respondida
Keeping count of consecutive of two vectors
I am not really sure what you mean by consecutively. But this may help you further: TF = A ==9 && B>= 212 will give you ...

más de 10 años hace | 0

Respondida
Problem with storing for-loop values in array
After the first iteration of the for-loop n has become 1. So for the next iteration, the while-loop is never entered. so _T(k)_ ...

más de 10 años hace | 0

| aceptada

Respondida
How to shuffle stimuli from two arrays for a randomised presentation in Psychtoolbox?
I would create an array with two columns. The first column says if it should be an old or new stimulus (1 or 2), the second colu...

más de 10 años hace | 0

Respondida
finding block with minimum mean in cell array?
Get the mean for each block using cellfun, and apply a sort to get the indices in order. M = cellfun (@(x) mean(x(:)), sali...

más de 10 años hace | 0

| aceptada

Respondida
How to improve the speed of of this function?
The command TRIAL1A_SPACE1 = T1A_raw_TEMP >= 8 & T1A_raw_HUM >= 11 will make create the required (logical) matrix.

más de 10 años hace | 1

Respondida
How to replace a number with 0 in an array
A = [1 2 3 ; 0.5 0.5 2 ; 0.5 5 6] % example data C = A(:,1) tf = C == 0.5 A(tf,1) = 0 % or in one line: % ...

más de 10 años hace | 0

Respondida
Flipping the numbers 1 to -1
help numel help for help rand help if help sum % for k=1:N % if ... % A(k) = -A(k) % B(k) = ...

más de 10 años hace | 1

Respondida
Storing numeric index of alphabetic character in text string
ix = find(ismember(lower(TS1),'a':'z'),1,'first')

más de 10 años hace | 0

Respondida
How can I find the correlation coefficient between the polynomial of best fit generated and my original data points?
Depending on your toolboxes, take a look at cftool, fit, or polyval

más de 10 años hace | 0

Respondida
How do I split a matrix into an array based on the elements in a single column without iterating through each row?
A single line of code using arrayfun: Array = arrayfun(@(k) A(A(:,2)==k,:), unique(A(:,2)), 'un', 0)

más de 10 años hace | 2

Respondida
Replacing elements of a logical index vector
X = logical([0 1 1 0 1 1 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1]) Y = fliplr(conv(fliplr(conv(double(X),[1 1],'same')),[1 1],'same')...

más de 10 años hace | 0

Respondida
Combine a number of vectors into a 2D color plot
Are all the vectors Zn of the same length? Then you can concatenate them into a single matrix with M rows (M is the number of sl...

más de 10 años hace | 0

| aceptada

Respondida
While loop not working properly
I am pretty sure you *do* use horzcat, albeit in the form [A B]. The error results from code similar to this: A = 1:3 ; ...

más de 10 años hace | 0

Respondida
How do you calculate the determinate of a matrix in matlab without using built in functions?
http://www.mathworks.com/matlabcentral/answers/245640-how-to-use-for-loops-to-calculate-the-determinant-of-the-first-n-powers-of...

más de 10 años hace | 0

Respondida
How to shift certain arrays in a matrix downward
This is a fast and easy-to-read solution: M = [1 4 6 9 0 2 3 6 8 8 2 5 2 5 6 8 9 0 3 5 7 ...

más de 10 años hace | 0

| aceptada

Respondida
how to remove padarray from image?
A = magic(4) n = 2 B = padarray(A,[n n]) % pad A2 = B(n+1:end-n,n+1:end-n) % unpad or directly: A2 = A

más de 10 años hace | 1

Respondida
Shifting a plot in the horizontal direction
The command plot(Y) plots the values of Y against their indices as x values. In general, however, it is a good idea to specify t...

más de 10 años hace | 1

| aceptada

Respondida
Why do I get a graph without a line when I try to plot the following equation?
It is not blank, as 51 small dots are plotted. Try this: plot (x,y,'bo') This is default behaviour for plot when y is a ...

más de 10 años hace | 1

| aceptada

Respondida
Finding Duplicate string values in two cell array 22124x1
Let *_C_* be your cell array of strings, then [UniqueC,~,k] = unique(C) N = histc(k,1:numel(UniqueC)) will give you ...

más de 10 años hace | 1

Respondida
multiple graph in one figure
Take a look at the function *hold* Create some data x = 1:10 y1 = 2*x+3 y2 = 3*x-4 plot(x,y1,'mo-') ; hold o...

más de 10 años hace | 0

Cargar más