Réponse apportée
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...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Finding averages in an array
To find the average across all matches mean(sum(X(:,6:7), 2))

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 10 ans il y a | 1

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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)))

plus de 10 ans il y a | 1

| A accepté

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

plus de 10 ans il y a | 1

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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 ...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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); ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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);

plus de 10 ans il y a | 1

Réponse apportée
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 ...

plus de 10 ans il y a | 2

Réponse apportée
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')

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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.

plus de 10 ans il y a | 0

Réponse apportée
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, ...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 2

| A accepté

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

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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)); ...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
How to set axis of scatter3?
axis([your values]) hold on

plus de 10 ans il y a | 1

Réponse apportée
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, []...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How to calculate the difference of means?
mean(data(x:y)) - mean(data(1:x-1))

plus de 10 ans il y a | 0

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

plus de 10 ans il y a | 0

| A accepté

Charger plus