how to write the randn' s code with just using rand and CLT
Since you don't actually want to use the CLT, then <https://en.wikipedia.org/wiki/Inverse_transform_sampling inverse sampling> i...

ungefär 6 år ago | 1

| accepted

How to make a table with multiple variables?
You've only created two vectors, not matrices. You're basically trying to divide a 1-by-5 by a 1-by-7 which doesnt work. What ...

ungefär 6 år ago | 0

| accepted

How to initialize a row vector with value zero of size 1xn?
Look up the documentation for the |zeros| function, which you are using: A = zeros(1,n);

ungefär 6 år ago | 2

| accepted

Plotting a mean line on a graph
%set up x = 1:0.1:10; r = sin(x); t = 1:91; x = mod(t,2) == 0; m_x = mean(r(x)); m_x2 = mean(-r(~x)); % plo...

ungefär 6 år ago | 0

minimize integral function for a parameter
I think you can do something like this. Make a file with your integral that takes in |k|: function [ F ] = int_fun(k) ...

ungefär 6 år ago | 0

Plotting an equation at different X
You should look up the |plot| function: incr = 0.1; x = [1:incr:20]; y = (1-x).^-1 plot(x,y)

ungefär 6 år ago | 0

| accepted

How can I create it?
Try this A = 2*cos(0.4.*pi.*(repmat([1:5]',1,5) - repmat([1:5],5,1)));

mer än 6 år ago | 0

Question

MCC in Matlab 2014b on Windows 10
This is a slightly esoteric question, but for some technical reasons I'm looking to use the Matlab runtime library compiler (mcc...

mer än 6 år ago | 1 answer | 0

### 1

Function evaluation in each iteration of pattern search exceeding 2* (number of optimization variable)
You have |'SearchMethod'| enabled. This is an optional step which performs a search prior to the polling, resulting in the larg...

mer än 6 år ago | 1

| accepted

The added variable plot is little bit complicated; basically, because you have a multi-variable regression, it is trying to give...

mer än 6 år ago | 2

| accepted

Integral of complicated function
There are a bunch of techniques you could use. Matlab has a built-in quadrature <http://www.mathworks.com/help/matlab/ref/integ...

mer än 6 år ago | 0

how to automatically open files and do the commands
You'll have to program this, but it's pretty straightforward. cd 'C:\Users\etc' %your file path with all the files. c = st...

mer än 6 år ago | 0

| accepted

Adding a legend manually for a plot generated by a loop
I think the issue is that you don't want to generate the plot like that; it's slow and makes it hard to label. Check out this s...

mer än 6 år ago | 1

| accepted

How to avoid this warning?
You've created a function named |plot| which has the same name as another function already in Matlab. To fix this, simply ren...

mer än 6 år ago | 0

How to save the variables inside for loop
The easiest way to probably to just use a <http://www.mathworks.com/help/matlab/ref/cell.html cell array>. Es = cell(100,1...

mer än 6 år ago | 2

| accepted

Plotting 1MHz sine wave
Just change this line: t = 0:1/N:S; to this t = 0:(1/N)*S:S; The issue was that you are telling Matlab to create...

mer än 6 år ago | 0

| accepted

separate column into several using descriptive variable
You want the <http://www.mathworks.com/help/matlab/ref/discretize.html discretize> function: x = 100*rand(1000,1); %your dat...

mer än 6 år ago | 0

Putting spacing between strings
You can do this by sending them to strings then concatenating them: A = 1; B = 8; C= 9; space = ' '; str ...

mer än 6 år ago | 1

Not enough input arguments for read an immage
Check out the <http://www.mathworks.com/help/images/ref/im2bw.html documentation>. The function |im2bw| needs two arguments: ...

mer än 6 år ago | 0

| accepted

Undefined function 'mtimes' for input arguments of type 'cell'.?
This expression: sigma=[{0.307*(c_n)^2}*{(2*3.1416/lamda)^1.17}*{L^(1.833)}]-[{0.742*(c_n)^2}*{(2*23.1416/lamda)^0.17}*{(L^...

mer än 6 år ago | 1

| accepted

How expand a matrix?
This should work A = [1 5 8 12 7 5 2 1]; floors = floor(A./3); C = cumsum(3.*ones(max(floors)+1,length(A)),1) A_p = re...

mer än 6 år ago | 0

| accepted

How can a plot from an "if" inside of a while loop?
Try this: N=input('The total number of particles in the system is:'); %The total number of particls in the system n...

mer än 6 år ago | 0

determining indices of double type cells in a cell array of char and double type cells
See if this solves your problem c = {'cat',1,'bird',22,'elephant',3}; %an example of data in the format you have ind = fin...

mer än 6 år ago | 1

| accepted

Genetic Algorithm fitness function for failing parameters
I think you probably want an <http://www.mathworks.com/help/gads/genetic-algorithm-options.html output function>. Basically...

mer än 6 år ago | 1

| accepted

Solve non linear equations system
You need to do a couple of steps. First, make a function which returns the equation you want optimized: function [F] = fun...

mer än 6 år ago | 0

| accepted

Remove help message from quadprog() function
You can call it like this: options = optimoptions('Display','off'); x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options); T...

mer än 6 år ago | 1

How can I add noise to linear graph
You never added the random noise to your dataset: sample = 100; x = linspace(-5,5); y= 1.6 * x +6; r = rand...

mer än 6 år ago | 1

| accepted

How can I make all the variables in an array 0 after the first time 0 occurs in the array
Generate your |x| as normal, with the many 1's afterwards then call: x = [1,1,1,1,1,0,0,1,1,0,0,0]; %generate x x(find(x =...

mer än 6 år ago | 0