Question


What you get with: (0:n-1)*n + 1:n
What you get with: n = 4; (0:n-1)*n + 1:n % 1 2 3 4 I was expecting: (0:n-1)*n + (1:n) % 1 6 11 16

15 years ago | 4 answers | 2

4

answers

Answered
Speed improvement of the random generator
Even generating all the random numbers at once (moving it outside of the loops the gain is small), but the difference lies in th...

15 years ago | 1

Answered
loops
A = [0 0 0 0 1 0 1 0 1 9 0 0 -1 0 -1 4 0 0]; A(3:5,2) = ...

15 years ago | 0

Answered
How to extract multi-format data from file?
Walter meant: fid = fopen('C:\Users\Oleg\Desktop\test.txt'); data = fscanf(fid,'%c,%f,%x,%x,%x;%c,%f,%x,%x,%x;%c,%f,%x,...

15 years ago | 0

Answered
if... then... else?
Try this solution: A = [97 100 93 89 86 80 93 94 95 92 80]; % Preallocate Out = ones(size(A)); % First elem...

15 years ago | 0

| accepted

Answered
histogram
[counts,x] = imhist(BW,100)

15 years ago | 0

Answered
Got error export data from workspace into database
The correct expression for an INSERT is: INSERT table_name VALUES (value1, value2, ...) or INSERT table_na...

15 years ago | 0

Answered
zero value in beronoulli trials !!!
Some other parenthesis mistakes corrected: N=10; P=0.5; K=0:N; M =exp(P.^K.*(1-P).^(N-K).*factorial(N)./(factorial...

15 years ago | 1

Answered
gaussian beam height plot
Can you be more specific? What do you want to do with the graph? Also, pdf map the domain into the [0 1] interval. You can't ...

15 years ago | 0

| accepted

Answered
neighbour pixel operation
Why did you group in cells in thr first place? Referencing the content of a cell should be done with curly brackets: r{1...

15 years ago | 0

| accepted

Answered
Plotting data on same axis as graph created by matlab function
Look at the solution I gave at *<http://www.mathworks.com/matlabcentral/answers/1177-plotting-a-normal-graph-with-a-candlestick-...

15 years ago | 0

Answered
how can two matlab user write/read single excel sheet via internet from differnt ends
Try to give a look at <http://www.mathworks.com/help/techdoc/ref/ftpclass.html ftp>

15 years ago | 0

Answered
Increase lengthof variable in a for loop by a certain increment.
Don't use length as a variable: length(start)= length(start)*0.5; You're creating _length_ as a variable which obfuscate...

15 years ago | 1

Answered
Plot question: Monthly data on yearly axis
You were using datenum incorrectly: startdate = datenum('31-01-2002','dd-mm-yyyy') enddate = datenum('31-12-2010','dd-mm...

15 years ago | 1

Answered
Truncating fractions
Matt's solution is working. Your question isn't specific enough. You want to display, and not to truncate. A=[0.0001 -0.0...

15 years ago | 0

Answered
.xml read
<http://www.mathworks.com/help/techdoc/ref/xmlread.html xmlread>

15 years ago | 0

Answered
Matlab letter "h" question
The letter "h" is there because you cannot name a matlab variable with just digits.

15 years ago | 0

| accepted

Answered
Using variables to name excel worksheets.
If _x_ is a number then you have to convert it into a string first: x = 10; xlswrite('excelfile.xls', 10, ['Delta =' spr...

15 years ago | 0

| accepted

Answered
Loading multiple datafile of different sizes
Store them in a cell array or in a structure, if you can't concatenate. for I = 0:29 filename = sprintf('Tension&CBResi...

15 years ago | 0

Answered
Index multiple elements in a vector using logical indexing
For comparison with multiple elements: D = C(ismember(A,B)) Also, avoid to use find when you don't need the coordinates.

15 years ago | 4

Answered
Determining number heartbeats the data.
If you have signal processing use <http://www.mathworks.com/help/toolbox/signal/findpeaks.html findpeaks>, or download one of th...

15 years ago | 1

Answered
making answer into array
Are you trying to do: a = [2 1 3 1 1 4 1 5 6 7 1 1 8 1 9 1]; sort(a,2) ans = ...

15 years ago | 0

| accepted

Answered
GENERATE MATRIX FROM VECTORS
x = 0:4:8; y = 0:5:15; numX = numel(x); numY = numel(y); y = repmat(y(:),numX,1); x = repmat(x ,numY,1); ...

15 years ago | 1

| accepted

Answered
Generation of a column with constants values that increases for different RANGE of row
1) A( 1:30,1) = 10; 2) A(31:60,1) = 18:8:10+8*30; 3) not clear

15 years ago | 1

| accepted

Answered
Plotting the variance. Please help fix my code
You can use this approach: % Supose you have an array of 73500 elements and you want to calculate the % variance on non...

15 years ago | 0

Answered
How to bring Quartly format time excel data to matlab
This is a duplicate post. Please refer to the answer I've given you here: <http://www.mathworks.com/matlabcentral/answers/3646...

15 years ago | 0

Answered
Converting to quarterly time from xls
You can import xls data with *<http://www.mathworks.com/help/techdoc/ref/xlsread.html xlsread>*: [data, text] = xlsread(filen...

15 years ago | 1

| accepted

Answered
Fonts with latex interpreter and no interpreter look different
Des using Tex (default) help? title('2 1.8 1.6 Title with latex character \pi')

15 years ago | 0

Answered
how to read a data file with textscan when the the data type is inconsistant
Couldn't find a way, then 2 solutions: 1) substitute in you file .#QNAN with empty '' and import afterwards, *<http://www.mat...

15 years ago | 0

Answered
MCMC
Hi, you don't any loop there: x = s(:,2); y = s(:,3); q = 1000; a = 9.9840; b = 9.9939; c = a + (b-a) * rand(...

15 years ago | 1

| accepted

Load more