Answered

How can I make a for loop with two diferent indexes

syms w; cnt = 1:.2:20; for ii=1:length(cnt) xi = fsolve(@(w) -tan(w/2) + w/2-4/ii*(w/2).^3,[1 3]*pi-.1); ...

How can I make a for loop with two diferent indexes

syms w; cnt = 1:.2:20; for ii=1:length(cnt) xi = fsolve(@(w) -tan(w/2) + w/2-4/ii*(w/2).^3,[1 3]*pi-.1); ...

8 years ago | 0

| accepted

Answered

code without for loop

idx = sub2ind(size(mask),index(:,1),index(:,2)); mask(idx) = 255;

code without for loop

idx = sub2ind(size(mask),index(:,1),index(:,2)); mask(idx) = 255;

8 years ago | 0

Answered

Adding a title to a graph

title(sprintf('Beam %s Beam \n%6.2f lb. applied to a %s %s'... ,'gold',200,'joist','pooter'),'fontweight','b'); This w...

Adding a title to a graph

title(sprintf('Beam %s Beam \n%6.2f lb. applied to a %s %s'... ,'gold',200,'joist','pooter'),'fontweight','b'); This w...

8 years ago | 0

| accepted

Answered

store string in array

What do you mean the INPUT function only lets you input one character? >> G = input('Enter a string: ','s') Enter a ...

store string in array

What do you mean the INPUT function only lets you input one character? >> G = input('Enter a string: ','s') Enter a ...

8 years ago | 0

| accepted

Answered

Is it possible to use exist function in a loop?

Did you try it? The help for EXIST indicates you can use it as you are doing.

Is it possible to use exist function in a loop?

Did you try it? The help for EXIST indicates you can use it as you are doing.

8 years ago | 0

| accepted

Answered

How to copy XTickLabels?

xticlabel is not a child of the axes, it is a property of the axes. f1=figure; ax1=axes; plot(data); set(gca,...

How to copy XTickLabels?

xticlabel is not a child of the axes, it is a property of the axes. f1=figure; ax1=axes; plot(data); set(gca,...

8 years ago | 0

| accepted

Answered

random permutation of 3 numbers when repetition of digits are allowed

Give this file a try: <http://www.mathworks.com/matlabcentral/fileexchange/11462-npermutek NPERMUTEK>. It solves the general pr...

random permutation of 3 numbers when repetition of digits are allowed

Give this file a try: <http://www.mathworks.com/matlabcentral/fileexchange/11462-npermutek NPERMUTEK>. It solves the general pr...

8 years ago | 1

Answered

How to populate a listbox from a pop up menu

Set the string property. set(handles.listbox1, 'string','Restaurant')

How to populate a listbox from a pop up menu

Set the string property. set(handles.listbox1, 'string','Restaurant')

8 years ago | 0

Answered

Plotting a Piecewise function?

First define this in an M-file: function [F] = myfunc(thet) % help F = zeros(size(thet)); idx = -pi/2 <= thet & th...

Plotting a Piecewise function?

First define this in an M-file: function [F] = myfunc(thet) % help F = zeros(size(thet)); idx = -pi/2 <= thet & th...

8 years ago | 0

Answered

What is the difference between exp and expm in terms of a matrix ?

<http://www.mathworks.com/help/matlab/ref/expm.html EXPM Documentation> If you look at that link, the difference is explained...

What is the difference between exp and expm in terms of a matrix ?

<http://www.mathworks.com/help/matlab/ref/expm.html EXPM Documentation> If you look at that link, the difference is explained...

8 years ago | 0

Answered

Generating A(i,j) = [i; j]

You want each element of your matrix to be a two element vector? That is not a matrix, but it does sound like a cell array. ...

Generating A(i,j) = [i; j]

You want each element of your matrix to be a two element vector? That is not a matrix, but it does sound like a cell array. ...

8 years ago | 0

| accepted

Answered

Vector imbalance error in while loop

You may have meant: y1(i) = (F.*x(i).^2/6*E*I).*(3*a-x(i)); % 0<x<a Otherwise you are trying to put numel(x) elemen...

Vector imbalance error in while loop

You may have meant: y1(i) = (F.*x(i).^2/6*E*I).*(3*a-x(i)); % 0<x<a Otherwise you are trying to put numel(x) elemen...

8 years ago | 0

| accepted

Answered

I'm getting a plotting length mismatch error but my lengths match

You are calling PLOT incorrectly. PLOT only takes the variables to be plotted and lineseries properties, not axes properties. ...

I'm getting a plotting length mismatch error but my lengths match

You are calling PLOT incorrectly. PLOT only takes the variables to be plotted and lineseries properties, not axes properties. ...

8 years ago | 1

| accepted

Answered

element wise multiplication and sum

I don't know where the 15 came from. I assume you mean 12. >> a = [1,2,3;4,5,6]; >> b = [2,2,2]; >> a*b.' % same...

element wise multiplication and sum

I don't know where the 15 came from. I assume you mean 12. >> a = [1,2,3;4,5,6]; >> b = [2,2,2]; >> a*b.' % same...

8 years ago | 2

| accepted

Answered

Error: Attempted to access x(101); index out of bounds because numel(x)=100.

You want 0 < x(i) && x(i) < a Your expressuon evaluates to: 1 < a Because MATLAB evaluates from left to right....

Error: Attempted to access x(101); index out of bounds because numel(x)=100.

You want 0 < x(i) && x(i) < a Your expressuon evaluates to: 1 < a Because MATLAB evaluates from left to right....

8 years ago | 0

| accepted

Answered

finding index of several values within a vector efficiently

idx = [1 2 5]; X = [1 5 4 3 2]; vals = X(idx) % linear indexing.

finding index of several values within a vector efficiently

idx = [1 2 5]; X = [1 5 4 3 2]; vals = X(idx) % linear indexing.

8 years ago | 0

Answered

how to create 2 matrices from 1 matrix depending on values 0 & 1, displayed in first column of 1st matrix?

Now I think I see what you did. You probably did not realize that the | symbol evaluates to logical OR when someone copies and ...

how to create 2 matrices from 1 matrix depending on values 0 & 1, displayed in first column of 1st matrix?

Now I think I see what you did. You probably did not realize that the | symbol evaluates to logical OR when someone copies and ...

8 years ago | 0

| accepted

Answered

what's the relation between a resolution and the size of pixel?

Sounds like it. Resolution is how many pixels per unit linear measure, so in the U.S. we would say 1/pixelsize = 1/(.254) =...

what's the relation between a resolution and the size of pixel?

Sounds like it. Resolution is how many pixels per unit linear measure, so in the U.S. we would say 1/pixelsize = 1/(.254) =...

8 years ago | 0

Answered

Why/How does MATLAB run faster when the workspace is full of variables?

I would be willing to bet that reason you experience the speed increase is that when you issue the CLEAR command you are not onl...

Why/How does MATLAB run faster when the workspace is full of variables?

I would be willing to bet that reason you experience the speed increase is that when you issue the CLEAR command you are not onl...

8 years ago | 2

| accepted

Answered

GUI Program Crash on .fig Load

More details may be necessary. Did you make all of the changes through GUIDE? Did you save them as you went (change-save-check...

GUI Program Crash on .fig Load

More details may be necessary. Did you make all of the changes through GUIDE? Did you save them as you went (change-save-check...

8 years ago | 0

| accepted

Answered

Can anyone help me to get this PV=nRT working? please.

Change your FOR loop to this: for jj=1:length(V) % Note, length(V), not 10! P1(jj)=T1*R*n/V(jj); P2(jj)=T...

Can anyone help me to get this PV=nRT working? please.

Change your FOR loop to this: for jj=1:length(V) % Note, length(V), not 10! P1(jj)=T1*R*n/V(jj); P2(jj)=T...

8 years ago | 1

| accepted

Answered

In an assignment A(I) = B, the number of elements in B and I must be the same.

Have a look at this: A([1 2 3]) = [8 7 6 8 7 9] % Error A([1 2 3]) = [8 7] % Error A([1 2 3]) = [8 7 6] % No error ...

In an assignment A(I) = B, the number of elements in B and I must be the same.

Have a look at this: A([1 2 3]) = [8 7 6 8 7 9] % Error A([1 2 3]) = [8 7] % Error A([1 2 3]) = [8 7 6] % No error ...

8 years ago | 0

Answered

Unexpected result for sin()

In general, you need to make your sample frequency sensitive to the signal frequency... (Nyquist) f = 50; x = 0:0.1/(...

Unexpected result for sin()

In general, you need to make your sample frequency sensitive to the signal frequency... (Nyquist) f = 50; x = 0:0.1/(...

8 years ago | 0

Answered

Output of the row of a vector which has the same entry as a second vector

You were close, but you want to switch the order of the arguments to ISMEMBER and use the two output call. % Original data ...

Output of the row of a vector which has the same entry as a second vector

You were close, but you want to switch the order of the arguments to ISMEMBER and use the two output call. % Original data ...

8 years ago | 0

| accepted

Answered

Fitting N(N-1) points on an NxN matrix

% Say your given vector is: X = [ 2 3 4 5 6 7 ]; % Now to make the matrix. L = (1 + sqrt(1+4*length(X)))/2; F = ...

Fitting N(N-1) points on an NxN matrix

% Say your given vector is: X = [ 2 3 4 5 6 7 ]; % Now to make the matrix. L = (1 + sqrt(1+4*length(X)))/2; F = ...

8 years ago | 0

| accepted

Answered

GUI data sharing problem?

Put the call to UIGETFILE in the callback for the pushbutton. Then immediately after the return, simply use the open the file a...

GUI data sharing problem?

Put the call to UIGETFILE in the callback for the pushbutton. Then immediately after the return, simply use the open the file a...

8 years ago | 0

Answered

In plotting Y(x)=10^x, for x=0:5 matlab gives y-axis tick labels as 0 1 2 3 4 and last as 5 x 10^5. How can I get all tick labels as 10^x?

You could use the MATLAB logarithmic plotting routines: x = 0:5; semilogy(x,10.^x) % Also, see SEMILOGX, LOLOG

In plotting Y(x)=10^x, for x=0:5 matlab gives y-axis tick labels as 0 1 2 3 4 and last as 5 x 10^5. How can I get all tick labels as 10^x?

You could use the MATLAB logarithmic plotting routines: x = 0:5; semilogy(x,10.^x) % Also, see SEMILOGX, LOLOG

8 years ago | 0

Answered

Bin my Data set

v = data(:,2); % Velocity mv12 = mean(v(v>=1 & v<=2)) % Mean of velocity on [1 2].

Bin my Data set

v = data(:,2); % Velocity mv12 = mean(v(v>=1 & v<=2)) % Mean of velocity on [1 2].

8 years ago | 0

| accepted

Answered

adding every element of an array with every element of another array?

A = 0:4; B = 10:16; bsxfun(@plus,A,B')

adding every element of an array with every element of another array?

A = 0:4; B = 10:16; bsxfun(@plus,A,B')

8 years ago | 0