답변 있음
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-')

대략 10년 전 | 1

| 수락됨

답변 있음
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...

대략 10년 전 | 1

| 수락됨

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

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

| 수락됨

답변 있음
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)...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

답변 있음
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'))

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

답변 있음
replace first elements from 1 col to numbers
help strrep help str2double

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

답변 있음
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)_ ...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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.

대략 10년 전 | 1

답변 있음
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: % ...

대략 10년 전 | 0

답변 있음
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) = ...

대략 10년 전 | 1

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

대략 10년 전 | 0

답변 있음
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

대략 10년 전 | 0

답변 있음
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)

대략 10년 전 | 2

답변 있음
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')...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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 ; ...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

| 수락됨

답변 있음
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

대략 10년 전 | 1

답변 있음
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...

대략 10년 전 | 1

| 수락됨

답변 있음
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 ...

대략 10년 전 | 1

| 수락됨

답변 있음
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 ...

대략 10년 전 | 1

답변 있음
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...

대략 10년 전 | 0

더 보기