Respondida
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...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

| aceptada

Respondida
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...

más de 10 años hace | 1

Respondida
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...

más de 10 años hace | 0

Respondida
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)))

más de 10 años hace | 1

| aceptada

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

más de 10 años hace | 1

Respondida
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...

más de 10 años hace | 0

Respondida
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 ...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

Respondida
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); ...

más de 10 años hace | 0

| aceptada

Respondida
Is this works in Matlab?! K = (N==INFECTED_A1) + (E==INFECTED_A1) + (S==INFECTED_A1) while INFECTED_A1=1. How can I get K=3?!
X = [N S Z K L M O P]; count = nnz(X==INFECTED_A);

más de 10 años hace | 1

Respondida
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 ...

más de 10 años hace | 2

Respondida
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')

más de 10 años hace | 0

| aceptada

Respondida
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...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

| aceptada

Respondida
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.

más de 10 años hace | 0

Respondida
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, ...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 2

| aceptada

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

más de 10 años hace | 0

| aceptada

Respondida
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)); ...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

Respondida
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...

más de 10 años hace | 0

| aceptada

Respondida
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...

más de 10 años hace | 0

| aceptada

Respondida
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...

más de 10 años hace | 0

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

más de 10 años hace | 1

Respondida
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, []...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

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

más de 10 años hace | 0

| aceptada

Cargar más