Answered

How to convert a string to a variable useable in a script?

I think you're like 99% of the way there. Z11='haar_net_scg_in1_2obsrv'; yfit11 = eval(strcat(Z11,'(Ind_vald)'); Thi...

How to convert a string to a variable useable in a script?

I think you're like 99% of the way there. Z11='haar_net_scg_in1_2obsrv'; yfit11 = eval(strcat(Z11,'(Ind_vald)'); Thi...

3 years ago | 0

| accepted

Answered

How to optimize this program using a for loop?

As far as I can tell, you're just doing this: fm1 = ifft(fft(fx)/norm(fx).*y); figure(1) plot(abs(fm1)) fm2 = if...

How to optimize this program using a for loop?

As far as I can tell, you're just doing this: fm1 = ifft(fft(fx)/norm(fx).*y); figure(1) plot(abs(fm1)) fm2 = if...

3 years ago | 0

| accepted

Answered

How to set linspace to infinity

No, this isn't possible because <http://www.mathworks.com/help/matlab/ref/linspace.html linspace> generates a uniformly spaced v...

How to set linspace to infinity

No, this isn't possible because <http://www.mathworks.com/help/matlab/ref/linspace.html linspace> generates a uniformly spaced v...

3 years ago | 0

| accepted

Question

Creating a block matrix of matrices?

I have a problem where I'm trying to create a matrix of the form [A B 0 0; 0 A B 0; 0 0 A B; 0 0 0 A]; However, this is i...

3 years ago | 2 answers | 0

Answered

Too many input arguments error. Matrix variable as input to objective function. Using ga algorithm.

As you've written it, your objective function does not take in any inputs. It needs to take in the point to be evaluated and ret...

Too many input arguments error. Matrix variable as input to objective function. Using ga algorithm.

As you've written it, your objective function does not take in any inputs. It needs to take in the point to be evaluated and ret...

3 years ago | 0

| accepted

Answered

How do you store all return values from a while loop in a vector in matlab ?

You can just store it as a vector: vector_choice_breakfast = cell(1000,1); count = 1; while breakfast_choicerep == 'Y' ...

How do you store all return values from a while loop in a vector in matlab ?

You can just store it as a vector: vector_choice_breakfast = cell(1000,1); count = 1; while breakfast_choicerep == 'Y' ...

3 years ago | 0

Answered

problem with matlab when trying to use a condition

You've opened a scoped environment. In order to end the scope, you need to use |end|: if i == 1 % do stuff end If y...

problem with matlab when trying to use a condition

You've opened a scoped environment. In order to end the scope, you need to use |end|: if i == 1 % do stuff end If y...

3 years ago | 0

Answered

Why is My Code Running So Slowly?

Try using the profiler, as per isakson recommends. This will give you an idea of what is taking up your time. MATLAB will use ...

Why is My Code Running So Slowly?

Try using the profiler, as per isakson recommends. This will give you an idea of what is taking up your time. MATLAB will use ...

3 years ago | 0

| accepted

Answered

OLS regression for bootstrapped data

To answer your question based on my comment. The command |Y = A(:,i)| selects the |i|-th column from the |A| matrix, so this wi...

OLS regression for bootstrapped data

To answer your question based on my comment. The command |Y = A(:,i)| selects the |i|-th column from the |A| matrix, so this wi...

3 years ago | 0

| accepted

Answered

How do I compare between 10 groups on a Ttest2?

Let's suppose you have them labeled |v1|, |v2|, ..., |v10| and they're the same size |n|. (If they're not the same size, use a ...

How do I compare between 10 groups on a Ttest2?

Let's suppose you have them labeled |v1|, |v2|, ..., |v10| and they're the same size |n|. (If they're not the same size, use a ...

4 years ago | 0

Answered

How to integrate SS y*exp(x) dxdy using matlab?

I think this should work; you want the |integral2| function. fun = @(x,y)(x.*exp(y)); ymin = @(x)(x/4); ymax = @(x)(...

How to integrate SS y*exp(x) dxdy using matlab?

I think this should work; you want the |integral2| function. fun = @(x,y)(x.*exp(y)); ymin = @(x)(x/4); ymax = @(x)(...

4 years ago | 0

| accepted

Answered

How to output multiple results via function

Do you mean from the function |fun|? It's pretty easy: function [f,yl,otherstuff] =fun(y,lambda) [y,fval]=fmincon(@...

How to output multiple results via function

Do you mean from the function |fun|? It's pretty easy: function [f,yl,otherstuff] =fun(y,lambda) [y,fval]=fmincon(@...

4 years ago | 0

| accepted

Answered

Define a text string and use in variable name throughout script

You can do this using the eval command, but you should AVOID it if possible. If there's any way to change the way those matrice...

Define a text string and use in variable name throughout script

You can do this using the eval command, but you should AVOID it if possible. If there's any way to change the way those matrice...

4 years ago | 0

Answered

Using table in MATLAB 2012

Matlab 2012 doesn't support the |table| function; it was implemented in R2013b. If you want to use that function, you will ne...

Using table in MATLAB 2012

Matlab 2012 doesn't support the |table| function; it was implemented in R2013b. If you want to use that function, you will ne...

4 years ago | 0

Answered

questions related with tic and toc ?

1) They're the sounds a mechanical clock makes. Tick, tock, tick, tock as the pendulum swings back and forth. 2) The value o...

questions related with tic and toc ?

1) They're the sounds a mechanical clock makes. Tick, tock, tick, tock as the pendulum swings back and forth. 2) The value o...

4 years ago | 0

| accepted

Answered

Parpool time to launch excessive

I'm going to answer this question for myself, approximately. It seems the issue was not specific to the MATLAB2014b compiler;...

Parpool time to launch excessive

I'm going to answer this question for myself, approximately. It seems the issue was not specific to the MATLAB2014b compiler;...

4 years ago | 1

| accepted

Answered

How do i improve this loop?

Your approach should work. Try this instead: Image3 = randn(10,10,3)+355; %example data mask = Image3(:,:,1) > 350 & Imag...

How do i improve this loop?

Your approach should work. Try this instead: Image3 = randn(10,10,3)+355; %example data mask = Image3(:,:,1) > 350 & Imag...

4 years ago | 0

Answered

function handle producing different output

Not sure what the deal is, but this works: A_vals = A(0.1:0.01:1); vals = 0.1:0.01:1; B_vals = B(0.1:0.01:1); plot(val...

function handle producing different output

Not sure what the deal is, but this works: A_vals = A(0.1:0.01:1); vals = 0.1:0.01:1; B_vals = B(0.1:0.01:1); plot(val...

4 years ago | 0

Answered

How to Solve a System of Equations with Multiple Variables

You can do this using numerical optimization by setting up an equation in which the objective function is the norm of the equati...

How to Solve a System of Equations with Multiple Variables

You can do this using numerical optimization by setting up an equation in which the objective function is the norm of the equati...

4 years ago | 0

Question

Parpool time to launch excessive

Hello everyone I'm working with a large server which is running a large computation. I've been trying to speed this up using...

4 years ago | 3 answers | 0

Answered

I need to make a set of 2000 random numbers between 0 and 1, with a mean of 0.5, with most of the numbers being either high or low (bimodal distrubution with peaks at 0 and 1)

m = randi([0,1],2000,1); r = abs(randn(2000,1)); r = r - min(r); r = r./max(r); num = m; num(m==0) = 0 + r(m==0); n...

I need to make a set of 2000 random numbers between 0 and 1, with a mean of 0.5, with most of the numbers being either high or low (bimodal distrubution with peaks at 0 and 1)

m = randi([0,1],2000,1); r = abs(randn(2000,1)); r = r - min(r); r = r./max(r); num = m; num(m==0) = 0 + r(m==0); n...

4 years ago | 0

Answered

How GlobalSearch optimization method works?

Basically, GlobalSearch takes a problem you've defined, which consists of an objective function and a solver, then repeatedly ru...

How GlobalSearch optimization method works?

Basically, GlobalSearch takes a problem you've defined, which consists of an objective function and a solver, then repeatedly ru...

4 years ago | 0

| accepted

Answered

Student or Education License, which?

It really depends on what you're trying to do. The Student license, if you have access to the license through your university, ...

Student or Education License, which?

It really depends on what you're trying to do. The Student license, if you have access to the license through your university, ...

4 years ago | 0

| accepted

Answered

What does command 'rng default;' do?

When Matlab generates random numbers, they're not truly random; they are based on a pseudo-random number generating algorithm. ...

What does command 'rng default;' do?

When Matlab generates random numbers, they're not truly random; they are based on a pseudo-random number generating algorithm. ...

4 years ago | 6

Answered

Undefined function or variable 'S', help!

You never define |S| in your function. You probably want something like this: function euler(func,S0,dt,t0,tf) % Time inte...

Undefined function or variable 'S', help!

You never define |S| in your function. You probably want something like this: function euler(func,S0,dt,t0,tf) % Time inte...

4 years ago | 0

Answered

How to remove some certain rows in Matlab?

Ah, I think I understand: the first column are IDs or something. This should work, using the |ismember| function with the |rows...

How to remove some certain rows in Matlab?

Ah, I think I understand: the first column are IDs or something. This should work, using the |ismember| function with the |rows...

4 years ago | 0

Answered

How to (1) accept user input while (2) keeping track of the number of character keys being pressed?

I think you can do it by making a customized version of |GetEchoString|. I don't have the toolbox, but the code looks simple <h...

How to (1) accept user input while (2) keeping track of the number of character keys being pressed?

I think you can do it by making a customized version of |GetEchoString|. I don't have the toolbox, but the code looks simple <h...

4 years ago | 2

| accepted

Answered

Random multiply by negative one

Try this: A = [1,-1]; rand_nums = A(randi([1,2],22528,1000));

Random multiply by negative one

Try this: A = [1,-1]; rand_nums = A(randi([1,2],22528,1000));

4 years ago | 0

Answered

Fitting using fit - i can't fit function without one constant [SOLVED]

Try this: %xdata = ...; %load your data %ydata = ... Le = 0.00025; Rm = 2.649; Mm = 0.00002; Cm = 0.00016; Bl = 10.5;...

Fitting using fit - i can't fit function without one constant [SOLVED]

Try this: %xdata = ...; %load your data %ydata = ... Le = 0.00025; Rm = 2.649; Mm = 0.00002; Cm = 0.00016; Bl = 10.5;...

4 years ago | 0

Answered

how do i copy figure in linux

Try this: bar(1:10) %whatever your figure is print('BarPlot','-dpng') There are other options here: http://www.mat...

how do i copy figure in linux

Try this: bar(1:10) %whatever your figure is print('BarPlot','-dpng') There are other options here: http://www.mat...

4 years ago | 0