Answered

How to find sign of a function

If you can evaluate your function with a command like y = yourFcn(x); then you can determine the sign with a logical var...

How to find sign of a function

If you can evaluate your function with a command like y = yourFcn(x); then you can determine the sign with a logical var...

nästan 10 år ago | 0

Answered

How can i simultaneously reference in cells

This is fun... you can try C{1}=[1 2;3 4;5 6] C{2}=[7 8;9 10;11 12] g = @(j)[C{1}(j,:);C{2}(j,:)]'; % function handle...

How can i simultaneously reference in cells

This is fun... you can try C{1}=[1 2;3 4;5 6] C{2}=[7 8;9 10;11 12] g = @(j)[C{1}(j,:);C{2}(j,:)]'; % function handle...

nästan 10 år ago | 0

| accepted

Answered

How to make an inset of matlab figure inside the figure.

Maybe try something like x1 = linspace(0,1); x2 = linspace(3/4,1); y1 = sin(2*pi*x1); y2 = sin(2*pi*x2); figure(1) % p...

How to make an inset of matlab figure inside the figure.

Maybe try something like x1 = linspace(0,1); x2 = linspace(3/4,1); y1 = sin(2*pi*x1); y2 = sin(2*pi*x2); figure(1) % p...

nästan 10 år ago | 33

Answered

Clearing part of an array

Since data is a row of cells, the syntax data{1,8} = {} actually sets the 8th entry of data equal to the empty cell. T...

Clearing part of an array

Since data is a row of cells, the syntax data{1,8} = {} actually sets the 8th entry of data equal to the empty cell. T...

nästan 10 år ago | 0

| accepted

Answered

Optimization algorithm into MATLAB

lsqcurvefit is a good candidate... whatever you choose, you'll need your objective to be written as a function

Optimization algorithm into MATLAB

lsqcurvefit is a good candidate... whatever you choose, you'll need your objective to be written as a function

ungefär 10 år ago | 1

Answered

Delete rows in a matrix that contain ONLY a negative number

Try isNegRow = all( A==-999, 2 ); A(isNegRow,:) = [];

Delete rows in a matrix that contain ONLY a negative number

Try isNegRow = all( A==-999, 2 ); A(isNegRow,:) = [];

ungefär 10 år ago | 2

Answered

How can I create a variable consisting of data from other (1,1) datasets

newVariable = [Pone,Ptwo,Pthree,Pfour]; ?

How can I create a variable consisting of data from other (1,1) datasets

newVariable = [Pone,Ptwo,Pthree,Pfour]; ?

ungefär 10 år ago | 0

Answered

computing matrices in a loop

Try using <http://www.mathworks.com/help/matlab/cell-arrays.html cells>, as in the example: for i = 1:4 % creates i-by...

computing matrices in a loop

Try using <http://www.mathworks.com/help/matlab/cell-arrays.html cells>, as in the example: for i = 1:4 % creates i-by...

ungefär 10 år ago | 1

Answered

How do multiple Answers in a post get Accepted?

Hahaha thanks @Matt J... Extra +1 to us for stumbling on the bug!

How do multiple Answers in a post get Accepted?

Hahaha thanks @Matt J... Extra +1 to us for stumbling on the bug!

ungefär 10 år ago | 2

Answered

Finding a noninteger value from an array

To do (1) and (2) try y = 0.7; % or y = 0.73; [~,idx] = min(abs(x-y)); % idx contains the index of the value in x cl...

Finding a noninteger value from an array

To do (1) and (2) try y = 0.7; % or y = 0.73; [~,idx] = min(abs(x-y)); % idx contains the index of the value in x cl...

ungefär 10 år ago | 1

| accepted

Answered

how to remove certain characters from a string in a file

Similar to @Srinivas, you could try str = '32/4/5'; str = regexprep(str,'/.*','');

how to remove certain characters from a string in a file

Similar to @Srinivas, you could try str = '32/4/5'; str = regexprep(str,'/.*','');

ungefär 10 år ago | 1

| accepted

Answered

Scatter plot with graduated marker colours

I wrote a function that is used in the following code as one way to accomplish what you're looking for. Download that function ...

Scatter plot with graduated marker colours

I wrote a function that is used in the following code as one way to accomplish what you're looking for. Download that function ...

ungefär 10 år ago | 0

Answered

Multivariable Optimization with the FMINCON Function

The key is to modify your objective function to be one that can be utilized by the fmincon interface. For example, if your ob...

Multivariable Optimization with the FMINCON Function

The key is to modify your objective function to be one that can be utilized by the fmincon interface. For example, if your ob...

ungefär 10 år ago | 4

Answered

hide one tail of errorbar

Have you tried something like x = linspace(0,1); y = x.^2; err = randn(size(x)); errorbar(x,y,zeros(size(x)),err)

hide one tail of errorbar

Have you tried something like x = linspace(0,1); y = x.^2; err = randn(size(x)); errorbar(x,y,zeros(size(x)),err)

ungefär 10 år ago | 1

| accepted

Answered

How do I run a program (.m) from simulink (.mdl) using a button?

One approach (short version): Add an annotation to your model, and write the command invoking your program in the annotation'...

How do I run a program (.m) from simulink (.mdl) using a button?

One approach (short version): Add an annotation to your model, and write the command invoking your program in the annotation'...

ungefär 10 år ago | 1

| accepted

Answered

Help with optimization tool

The error is occuring because the optim tool is trying to call test2() with a vector input, but you do not declare a vector inpu...

Help with optimization tool

The error is occuring because the optim tool is trying to call test2() with a vector input, but you do not declare a vector inpu...

ungefär 10 år ago | 0

| accepted

Answered

How to change the x ticket lables in a plot?

Try x = 1:12; y = x.^2; plot(x,y); tickLocations = [3,6,9]; % change to whatever you want tickLabels = {'3'...

How to change the x ticket lables in a plot?

Try x = 1:12; y = x.^2; plot(x,y); tickLocations = [3,6,9]; % change to whatever you want tickLabels = {'3'...

ungefär 10 år ago | 0

Answered

how to convert Cell to string

Modify the command cellfun(f1, num2cell(v),'UniformOutput', false) to cellfun(f1, v,'UniformOutput', false) ...

how to convert Cell to string

Modify the command cellfun(f1, num2cell(v),'UniformOutput', false) to cellfun(f1, v,'UniformOutput', false) ...

ungefär 10 år ago | 1

| accepted

Answered

How to calculate sum of specific array elements

Try x = [ 3 5 2 10 6 4]'; q = [ 0 0 1 2 3 3]'; % note first input must be column vector with positive integers (ind...

How to calculate sum of specific array elements

Try x = [ 3 5 2 10 6 4]'; q = [ 0 0 1 2 3 3]'; % note first input must be column vector with positive integers (ind...

ungefär 10 år ago | 2

| accepted

Answered

WHY THIS ERROR OCCUR ''??? Subscript indices must either be real positive integers or logicals."

Rethink how you're defining/using the variable tn

WHY THIS ERROR OCCUR ''??? Subscript indices must either be real positive integers or logicals."

Rethink how you're defining/using the variable tn

ungefär 10 år ago | 0

Answered

save a data as mat file

try save yourMatFile.mat compact_data

save a data as mat file

try save yourMatFile.mat compact_data

ungefär 10 år ago | 0

| accepted

Answered

problem with For loop

You are only plotting a single point... That is, the variables r and phi are only scalars (1x1 doubles) when you define x1 and x...

problem with For loop

You are only plotting a single point... That is, the variables r and phi are only scalars (1x1 doubles) when you define x1 and x...

ungefär 10 år ago | 0

| accepted

Answered

How to include a function into the main directory

You can add the directory containging your function to the MATLAB search path. Try doc pathtool

How to include a function into the main directory

You can add the directory containging your function to the MATLAB search path. Try doc pathtool

ungefär 10 år ago | 0

| accepted

Answered

How do I generate several datasets of random noise on MATLAB?

The command N = randn(1440,1000); will generate 1000 datasets comprising 1440 Gaussian random numbers and store them as ...

How do I generate several datasets of random noise on MATLAB?

The command N = randn(1440,1000); will generate 1000 datasets comprising 1440 Gaussian random numbers and store them as ...

ungefär 10 år ago | 0

Answered

Displaying in command winodw but i need to store in .txt file

The following code is not ideal in that two for loops are being used where one would suffice. However, it makes it clear which ...

Displaying in command winodw but i need to store in .txt file

The following code is not ideal in that two for loops are being used where one would suffice. However, it makes it clear which ...

ungefär 10 år ago | 0

Answered

how do I count the number of identical rows in a matrix?

Let the N-by-2 matrix you're working with be denoted A. Then, you can get a vector of size M-by-2 containing the unique rows ...

how do I count the number of identical rows in a matrix?

Let the N-by-2 matrix you're working with be denoted A. Then, you can get a vector of size M-by-2 containing the unique rows ...

mer än 10 år ago | 1

Answered

Looping for Markov Chain

You have all the pieces... its just awkward to organize (below I use cells) and display.. Try something like n = 100; P...

Looping for Markov Chain

You have all the pieces... its just awkward to organize (below I use cells) and display.. Try something like n = 100; P...

mer än 10 år ago | 0

Answered

extract seconds from timestamp in cell

I assume that the timestamp is represented as a string like: C{1} = '2011-04-19T01:01:59.000Z'; Then, try timeStam...

extract seconds from timestamp in cell

I assume that the timestamp is represented as a string like: C{1} = '2011-04-19T01:01:59.000Z'; Then, try timeStam...

mer än 10 år ago | 1

Answered

How can I create a vector of 10 random numbers?

If you use an approach like x = rand(20,1); idx = randi(20,10,1); x(idx) = NaN, you may replace less than ten numb...

How can I create a vector of 10 random numbers?

If you use an approach like x = rand(20,1); idx = randi(20,10,1); x(idx) = NaN, you may replace less than ten numb...

mer än 10 år ago | 0

Answered

How to save the output of a function in an array or cell?

I'm going to assume that the function which returns a matrix with r rows and 2 columns is named returnTwo.m Then use som...

How to save the output of a function in an array or cell?

I'm going to assume that the function which returns a matrix with r rows and 2 columns is named returnTwo.m Then use som...

mer än 10 år ago | 0