Answered
i have a problem with symsum
Probably the yf is wrong: yf = symsum((r^-mu) , j, 1, 3)./(r^-mu); ==> the result is 3 for yf (the result take the same ...

9 years ago | 0

Answered
Plotting 100 rows from 10000 rows automatically?
data = rand(10000, 6); for i= 1:10 i1 = (i-1)*100 + 1; i2 = i1+100 - 1; subplot(2,5,i), plot(data(i1:i2,...

9 years ago | 1

Answered
Adding a second axis
You can use text to place the labels, like text(150, 0, '265', 'HorizontalAlignment', 'center')

9 years ago | 1

| accepted

Answered
How to draw tangent line in a curve?
You can compute the slope with diff. Next you have to compute the y-values for x = 0 and x = 1 and plot the line. This link give...

9 years ago | 0

Answered
Saving images in JPG format, as grayscale, but i get white image in full
You should scale the images to the range 0,1 before writing to file.

9 years ago | 0

Answered
For loop not initiated
I have created some sample values for cent and the program runs just fine, entering the second loop as expected. The reason that...

9 years ago | 0

Answered
2d Plot with 3 Axes
You question is not entirely clear to me. But in principle you can achieve such a plot quite simple: y = [1:10; 10:10:100];...

9 years ago | 0

Answered
How to Convert a Logical Vector to a Character Vector?
strrep(strrep(sprintf('%d ', A), '1', 'yes'), '0', 'no')

9 years ago | 2

Answered
In an assignment A(:) = B, the number of elements in A and B must be the same.
What is size(max) size(Cindex) both must be the same.

9 years ago | 0

| accepted

Answered
Generate a set of 1000 elements where each element is a set of 40 elements
You can use cell arrays. But why don't you want to use matrices?

9 years ago | 0

Answered
find indices in a large array and replace them with zeros
for i = 1:10 index1(i,:) = signal(peak(i):(peak(i)+150)); index2(i,:) = signal((peak(i)-150):(peak(i)-1)); en...

9 years ago | 0

| accepted

Answered
Launching external program from matlab
Before you load the .mat file you can wait until the file exists while ~exist('yourmatfile.mat', 2); end

9 years ago | 0

| accepted

Answered
how to share data between different m files
I would write a three functions, as Stephen suggested. But if you insist that all variables need to have the same name in all fo...

9 years ago | 0

Answered
Matrix dimensions must agree.
c = 1000*ones(size(H1));

9 years ago | 0

| accepted

Answered
How do I get the closest values of an array stored for a particular input ?
[~, ind]= sort(abs(A-b)); A(ind(1:2))

9 years ago | 1

Answered
i want to calculate the equation:
I = [5 6 7 8 ; 2 8 6 3 ; 4 0 4 2 ; 5 0 1 0]; [l, ~, iI] = unique(I); nk = accumarray(iI, 1); XT = l'*nk/numel(I)

9 years ago | 0

| accepted

Answered
randperm(n,k) in R2011a
We cannot have a look into the randperm function. So if it is essential for you program to produce the same sequence of random n...

9 years ago | 0

Answered
Set axes properties in a loop
In this case I think that the for loop is kind of overkill. Without a loop, it is much easier to understand what's going on: ...

9 years ago | 0

Answered
Tight Boundary around a Set of Points
[ux, ia, ib] = uniquetol(x, 0.01); for i= 1:max(ib), M(i,:) = [min(y(ib == i)) max(y(ib == i))]; end plot(x, y, '.') ...

9 years ago | 3

| accepted

Answered
create vector with no repeated triplet sequences based on another vector
Just reverse order: B = fliplr(A);

9 years ago | 0

Answered
How to draw special figures like this:
val = [1 1 2 3 2 1 3 1 2 2 3 2 2 2 4 4]; col = [1 1 0; 1 0 0; 0 1 0; 0.5 0.5 0.5]; axes hold on for i = 1:numel(va...

9 years ago | 0

| accepted

Answered
Rewriting a vector addition and multiplication.
Repmat is your friend here: D = repmat(sum(A.^2, 2), [1, N2]) + repmat(sum(B.^2, 2)', [N1, 1]) - 2*A*B'; or as a one-lin...

9 years ago | 0

| accepted

Answered
Using imagesc to plot two matrices on top of each other with different colormaps?
This is a bit tricky, because you need two colormaps combined in a single colormap and scale the values in one image to match th...

9 years ago | 0

| accepted

Answered
how do I copy existing subplots and aggregate them into larger subplots
You can initialise spno = 1; % current subplot number and then replace your 4 subplot commands with subplot(2,2, sp...

9 years ago | 0

Answered
How can I compare vector`s values?
Index of extrema: b = b(:); idx = find(([b(1); b(1:end-1)] - b).*([b(2:end); b(end)] - b) > 0); Difference betwe...

9 years ago | 0

| accepted

Answered
finding elements in a matrix`
X=[1 2; 3 9; 3 10; 2 4] x = [2 9]; X = X(any(ismember(X, x),2), :); s = [X zeros(size(X,1), 1)]; You also kee...

9 years ago | 0

Answered
How to create the same random number in both c++ and Matlab?
I would create a routine that writes the initial random numbers generated by the C code to a file and then read this file in Mat...

9 years ago | 0

| accepted

Answered
averaging files with different dates
years = 1978:2009 for y = years pattern = sprintf('*_%d.txt', y); d = dir(pattern); Nfiles = num...

9 years ago | 0

| accepted

Load more