Réponse apportée
Can I plot rectangles without rescalling axis limits?
You need to post complete example code. I see no problems with this: ezplot(@sin) hold on rectangle('Position', [...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
Bargraph from variable length structure
As long as your x data does not contain duplicates: % Data. Note the x has no duplicates. variable.dataset(1).x = [1 2...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
is it possible to increment color and markers automatically for a plot in a loop?
You can do this: set(0,'DefaultAxesLineStyleOrder',{'+','o','*','.','x','s','d','^','v','>','<','p','h'}); Then look: ...

plus de 13 ans il y a | 0

Réponse apportée
selecting particular elements from a cell array
idx = all(cellfun(@(x) ~isequal(x,0),A(:,[1 3])),2) R = A(idx,[1 3 4 5])

plus de 13 ans il y a | 1

| A accepté

Réponse apportée
take line sum of part of matrix
Another: % Given data A = [1, 2, 54, 4, 5, 6;... 1, 2, 88, 4, 5, 6;... 1, 2, 0, 4, 5, 6]; b = [5;...

plus de 13 ans il y a | 2

Réponse apportée
HOW TO MOVE THE ELEMENTS BACK IN ORDER IN MATRICS WHICH ARE BEEN MOVED DIAGONALLY
Are you asking how to undo what your code does? for jj = -size(I,1) + 2 : size(I,2) - 2 a = diag(idx,jj); ...

plus de 13 ans il y a | 1

| A accepté

Réponse apportée
Does isdouble works in MATLAB
A = magic(3); B = single(A); isa(A,'double') isa(B,'double') If you need the isdouble function but don't have it, ...

plus de 13 ans il y a | 2

Réponse apportée
for loop options in Matlab
A = magic(5) cnt = 1; for jj = A disp(['Column #' num2str(cnt)]) disp(jj), cnt = cnt+1; end

plus de 13 ans il y a | 1

Réponse apportée
Anonymous function hyperbolic function code
When asking for help, please be as specific as possible. You get errors? *WHAT ERRORS*? snh = @(x) (exp(x)-exp(-x))/2 ...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
sum every 24 rows in a vector
If A is 8760-by-1, and you want to find the sum of every 24 elements, such that you will end up with 365 sums, then do: sum...

plus de 13 ans il y a | 5

| A accepté

Réponse apportée
How to update matrix values using algorithm based on position?
The straightforward way is to just use a loop: A = zeros(n); for ii = 1:n for jj = 1:n A(ii,jj) = 1/(ii+j...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
How to manipulate data provided by a user via a dialog box?
With cell array you have to access the contents using curly braces. Also note that the data is a string, not a number. ...

plus de 13 ans il y a | 1

| A accepté

Réponse apportée
Help with finding zero spots (fzero)
Here is a solution that uses your m-file function. Roots(1) = fzero(@f,0); Roots(2) = fzero(@f,2); Roots(4) = fzero(@...

plus de 13 ans il y a | 0

Réponse apportée
Preventing repeated sequences in a matrix
I think I figured out that Shuffle is on the FEX. Part of the problem is that you are just going to have more chance to get 3...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
how to create while statement
while ~all(A==1) % code here that changes A end

plus de 13 ans il y a | 1

| A accepté

Réponse apportée
Constructing a matrix from several diagonal matrixes (the code is included)
Replace your second loop with this: M = zeros(size(A)); for dd = min(v):max(v) Mcal = (diag(A,dd)+differance(a)...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
Correct Sprintf use on legend
Use: \\pm % The first \ escapes the use of the escape \. instead of: \pm

plus de 13 ans il y a | 1

| A accepté

Réponse apportée
How can I compute Jacobi Elliptic Functions in Matlab where the modulus is > 1?
Use (for m>1): sn(u,m) = sqrt(1/m)*sn(u*sqrt(m),1/m) cn(u,m) = dn(u*sqrt(m),1/m) dn(u,m) = cn(u*sqrt(m),...

plus de 13 ans il y a | 0

Réponse apportée
Question about variable in a vector.
You cannot rely on mixing types in a regular array. [3 4 A] may return an error message if A is not defined, or if A is n...

plus de 13 ans il y a | 0

Réponse apportée
sum() function in different Matlab version give different result
How different are the results, percent-wise? It is possible that the underlying algorithm has changed, and of course the or...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
stem3 with log axis - recovering stems
What happens is that a stem plot has the lines with on point on the z=0 plane. Taking the log of this throws this point to -inf....

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
How to use scroll bar to view number of axes in the given figure window.
Here is an example. function [S] = scroll_plot() % Scroll through 8 plots. S.fh = figure('units','pixels',....

plus de 13 ans il y a | 0

| A accepté

Discussion


Share your favorite snippet or utility
I am wondering what others use for those little short-cuts or niceties in MATLAB. I have in mind something you wrote or somethi...

plus de 13 ans il y a | 8

Question


Share your favorite snippet or utility
I am wondering what others use for those little short-cuts or niceties in MATLAB. I have in mind something you wrote or somethi...

plus de 13 ans il y a | 11 réponses | 8

11

réponses

Réponse apportée
dimension mismatch error in Matlab
With code like this: A(i,:)=B(1,:); % Assume i is a scalar... you need to make sure that: size(B,2)==size(A,2) ...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
compute the mean of a field in a struct
The mean of 19 and 24 is *not* 33.5. mean([student.age])

plus de 13 ans il y a | 5

| A accepté

Réponse apportée
Questions about Fractions and integers?
A = 9; % Also try with A = 7/8; if floor(A)==A disp('Integer') else disp('fraction') end

plus de 13 ans il y a | 0

Réponse apportée
Updating Table Data not working
Where is the second piece of code in relation to the first piece? Strange, because it works just fine here: RN = {'a','b...

plus de 13 ans il y a | 0

| A accepté

Réponse apportée
Warning: Unable to interpret LaTeX string
First of all you really should learn to use SPRINTF instead of EVAL. Please look at the help for SPRINTF and do not use EVAL in...

plus de 13 ans il y a | 3

Réponse apportée
Difference Subtracting Double Precision from Single Precision
Yes, have a look at E = eps(b) When you convert to single you are going to get the nearest single value to a within E. ...

plus de 13 ans il y a | 0

| A accepté

Charger plus