Answered
Nested function global variable
Add global m to your fun2; I also used point-wise multiplication and exponentiation to make it work. function T = fun(theta...

10 years ago | 0

| accepted

Answered
Finding averages in an array
To find the average across all matches mean(sum(X(:,6:7), 2))

10 years ago | 0

| accepted

Answered
6*0.003125 - 0.018750 = 0, right? How to get the right answer?
You can compare the results against the machine precision eps and regard them as equal if smaller than eps 6*0.003125 - 0.0...

10 years ago | 1

Answered
Shannon fano code error
if(sum(input_symbols)- add_prob <= 0.5) if false, first_half and second_half are not computed in shannon_split, so the output ar...

10 years ago | 0

Answered
what should i do to to evaluate the total length of a trajectory obtained as the sum of the distances of a point from the next??
If AP and ML are vectors, you can use L = sum(sqrt(diff(AP).^2 + diff(ML).^2)); Lap = sum(abs(diff(AP)))

10 years ago | 1

| accepted

Answered
unknown numbers of input
Creating dynamically named variables should be avoided. Just use A(i,:) to get you desired vectors.

10 years ago | 1

Answered
How to correct the order of colours while using legend command?
This is the expected behavior of the legend function. If you want another order, the simplest way is to change the order of plot...

10 years ago | 0

Answered
The working of perms
Have a look at perms(1:3) The result you get with perms('abc') is analogous to this. To have lexicographic order, use ...

10 years ago | 0

Answered
I'm struggling to plot this graph
a1 = 0.58; a2 = 0.47; Tstar = 283; dT = 24; aeq = @(T) a1 - 0.5*a2 *(1 + tanh((T-Tstar)/dT)) T = 250:310; pl...

10 years ago | 0

Answered
How to pass control from one loop to the other loop
invert = 1; for i = 1:numel(u) if u(i) == 0.01 invert = -invert; elseif invert<0 u(i) = -u(i); ...

10 years ago | 0

| accepted

Answered
How can I use a nested for loop to find multiple minimum values in a matrix array?
Simplify your code by using a linear index ind = 1; minval = A(ind); for i =1:numel(A) if A(i) < minval ...

10 years ago | 2

Answered
plotting of polar and Cartesian coordinates at the same time
y = rand(1,360); plot(linspace(-1,1, numel(y)), y+1) hold on plot(cos(theta).*y, sin(theta).*y, 'r')

10 years ago | 0

| accepted

Answered
How to take a random sample of each column?
data=importdata('wine.txt'); nRows=150; randomlySelected=data(randsample(size(data,1), nRows), :); if you don't have ran...

10 years ago | 0

Answered
Editing/Changing a text file's content based on input variable
The idea is that you run the regexpr N times using the 'once' parameter. And you don't need so save the file intermediately afte...

10 years ago | 0

| accepted

Answered
How do i vectorize an image?
Why don't you just get your vectors from A using A(:,i); I can see no reason why a you need to re-organize your data.

10 years ago | 0

Answered
How can I combine the separated H, S, V components into a single image?
If you store the individual layers in H, S, and V, you can assemble them along the third dimension using HSV = cat(3, H, S, ...

10 years ago | 0

Answered
Editing colors in the legend
You can create each plot with a handle hi, of which you store only the first entry in h. Now you can use this handle h as the fi...

10 years ago | 2

| accepted

Answered
.txt file importation with for loop
i = 8; filename = sprintf('/Users/.../-=C%d.txt', i) or filename = ['/Users/.../-=C' int2str(i) '.txt'] BTW '...'...

10 years ago | 0

| accepted

Answered
Launch an algorithm in several samples extracted from an image
Why not for m=1:92; result = activecontour(svf(xy_points(m,1)-2:xy_points(m,1)+2,xy_points(m,2)-2:xy_points(m,2)+2)); ...

10 years ago | 0

Answered
Infinite while loop for iterating data
You can compute the distances between all pairs as allpairs = nchoosek(1:8,2); for i=1:numel(allpairs) i1 = allpairs(i...

10 years ago | 0

Answered
Calculate midpoints between extrema in a picture
You can compute the mid points between every combination of extrema. Or only the midpoints between extrema that are within a...

10 years ago | 0

Answered
Combine 3 matrices (3D)
It is not entirely clear to me what you are asking for. 1. So far you have just coordinates for X, Y, Z, presumably generated...

10 years ago | 0

Answered
corresponding legends for each curves in one plot
I generate some fake data with for i=1:numberfile, eval(['C' int2str(i) '=rand(10,10);']), end and the code works fine f...

10 years ago | 0

| accepted

Answered
Writing equation in a Taylor Series?
No, you don't need the previous=difference line, it's wrong. Also count starts at 1 in the formula but at 0 in your code. The...

10 years ago | 0

| accepted

Answered
Point out the error from this code
Your i runs from 1 to length(n), and you try to address x(i-5), x(i-2), i.e, x(-4), x(-1) for i=1. That's wrong, indices have to...

10 years ago | 0

Answered
How to set axis of scatter3?
axis([your values]) hold on

10 years ago | 1

Answered
3 dim plot, how to specify color for each point
x = linspace(0,pi); y = x; z = sin(x+y); col = jet(numel(x)); % sample color from jet colormap scatter3(x,y,z, []...

10 years ago | 0

| accepted

Answered
How to calculate the difference of means?
mean(data(x:y)) - mean(data(1:x-1))

10 years ago | 0

Answered
Can anyone please check my codes? the figure doesn't show up!!!!
Try without an explicit isovalue isosurface(x,y,z,wavefn)

10 years ago | 0

| accepted

Load more