답변 있음
Loop for creating Submatrix
It should not be two nested loops. You can use one loop that increases a counter. You can use this code that doesn't need a loo...

2년 이하 전 | 0

| 수락됨

답변 있음
How to enter a function into matlab
H/2*sigma.*cosh(k.*(h+z))./sinh(k.*h).*cos(k.*x-sigma.*t) H/2*sigma.^2.*cosh(k.*(h+z))./sinh(k.*h).*sin(k.*x-sigma.*t)

2년 이하 전 | 0

| 수락됨

답변 있음
Index in position 1 exceeds array bounds (must not exceed 2 )
try this for i = j:size(A,1)

2년 이하 전 | 0

답변 있음
Shadow on xy plane of line in plot3?
use surfc function but you need a grid in x and y directions

2년 이하 전 | 0

답변 있음
Least squares regression to find coefficients
one solution is: [length(x) sum(x); sum(x) sum(x.^2)]\[sum(y) ; sum(x.*y)]

2년 이하 전 | 0

답변 있음
How to plot this eqaution
t=0:.001:1.0; s4 = cos(80*pi*t-10*pi).*(t>0.5 && t<=1.0);

2년 이하 전 | 1

| 수락됨

답변 있음
how can we solve non-linear equations like this via MATLAB, I am trying to solve it by using following program but it shows error, shown below in the pic? Thanks in advance.
eqns = [2*u + v == 0, u - v == 1]; S = solve(eqns,[u v]) clear syms a1 a2 a3 a4 eqn1 = cos(a1)+cos(a2)+ cos(a3)+ cos(a4) ==3...

2년 이하 전 | 0

답변 있음
Why is there a difference in the error when using "syms approach" and "@(x) approach" while defining functions in MATLAB?
Method 2 is an approximate method for finding the derivative of a function

2년 이하 전 | 0

답변 있음
Writing data into a text file - fprintf
You should use variables like ReactionTime as global Use this code after the function definition: global ReactionTime cd Use ...

2년 이하 전 | 0

답변 있음
How to generate a matrix with assigned probability?
% x is the probability of 1 % m rows and n columns A=binornd(1,x,n,m)'; % another random matrix A=binornd(1,x,n,m)';

2년 이하 전 | 1

답변 있음
Index from one vector to different sized vector
% v1 the first vector % v2 the matrix [~, ~, i2] = intersect(v1, v2(:,1)); newMatrix = v2(t2,:);

2년 이하 전 | 0

답변 있음
Roll a 6-sided die until you have rolled a total of 25 6's.
find(cumsum(randi(6,1,1000)==6)==25,1)

2년 이하 전 | 0

답변 있음
calling a function in a different script.
One solution is that you can use this command at the top of the files that use 'r' global r; Just after function definition...

2년 이하 전 | 0

답변 있음
Why does my code output answers in log?
Use double(solve([1000000==300*((((1+0.08/12)^(n+1)/(0.08/12)-1)))])) to solve this financial problem (interest rate)

2년 이하 전 | 1

| 수락됨

답변 있음
How to return an array to single value?
The size of x is different from G and Tamb

2년 이하 전 | 0

답변 있음
Plotting functions using loop
lambda=1; gamma1=0.3; n=0:1:15; P1 = (lambda.^n)./(lambda+gamma1).^(n+1)); plot(n, P1);

2년 이하 전 | 0

| 수락됨

답변 있음
Negative indexing of an array
There is no non-positive indexing in Matlab. you can use x(end) for the last member, x(end-1) the member before the last membe...

2년 이하 전 | 0

답변 있음
How i can write this in matlab in optimized form using intermediate variables????
sy = sin(y); asy = abs(sy); xt = x + tan(y); xtn = x + log(abs(tan(y))); tx = 2*x+sy^2; ot =1/3; R1 = abs(x)*xt/(50*x^2+as...

2년 이하 전 | 0

답변 있음
How i can write this in matlab??? x=-1.75*10^-3; y=3.1*pi;
R1 = abs(x).*(x+tan(y))./(50*x.^2+abs(sin(y))).^(1/3)+(5*x.^2+abs(sin(y))).^2.2./(x.^2 .* (x+tan(y)).^4); R2 = sinh(sqrt(2*x+(s...

2년 이하 전 | 1

| 수락됨

답변 있음
Number of odd numbers in an array
function n = myNOdds(x) n = sum(mod(x,2)==1); end

2년 이하 전 | 1

| 수락됨

답변 있음
Output of a for loop
You can use this code: %%Acting Forces on the beam and position F2=(-4); x2=0.4; L=1; %Constant EI Assumed 100 kN.m^2 (fr...

2년 이하 전 | 0

| 수락됨

답변 있음
I'm trying to get a vector from a loop without doing the linspace function
vector = zeros(1,5); j = 1; for i = 0:1.25:5; vector(j) = i; j = j+ 1; end disp(vector)

2년 이하 전 | 0

답변 있음
Graph line not showing
Several issues in your code: 1- it has only one point (use plot(x, y) ) 2- The angle should be in radians not degrees. For ang...

2년 이하 전 | 0

답변 있음
How do I write the following in matlab ?
H1 = (x.*(1+x.^2).*(1+2*x).^2).^2.3 ./ log(abs(cot(y))) + (log(abs(cot(y)))-x) ./(x.*(1+x.^2).*(1+2*x).^2); R2 = sinh(sqrt(2*x+...

2년 이하 전 | 0

답변 있음
Can you help me write the following in matlab ?
H1 = (x*(1+x^2)*(1+2*x)^2)^2.3 / -log(abs(tan(y))) + (-log(abs(tan(y)))-x) /(x*(1+x^2)*(1+2*x)^2); R2 = sinh(sqrt(2*x+(sin(y)^2...

2년 이하 전 | 0

답변 있음
How do I write the following in matlab ?
H1 = (x*(1+x^2)*(1+2*x)^2)^2.3 / -log(abs(tan(y))) + (-log(abs(tan(y)))-x) /(x*(1+x^2)*(1+2*x)^2); R2 = sinh(sqrt(2*x+(sin(y)^2...

2년 이하 전 | 0

답변 있음
Plot only equilateral triangles
figure, hold on e = 0.01; i=0; while i<= 10 x = rand(3,1); y = rand(3,1); c = rand(3,1); L1 = sqrt((x(2)-...

2년 이하 전 | 0

| 수락됨

답변 있음
Plot only equilateral triangles
figure, hold on e = 0.0001; i=0; while i<= 10 x = rand(3,1); y = rand(3,1); c =rand(3,1); L1 = sqrt((x(2)...

2년 이하 전 | 0

답변 있음
How to enter multiple values for a single input in a function
Most Matlab functions are vector based. you should use .^ for vector based ^ and .* for vector based * So you function line loo...

2년 이하 전 | 0

더로드