Respondida
How to draw a curly brace outside the gca?
Use negative ccordinates for the brace byt xlim from 0 drawbrace([-0.5,3], [-0.5,8], 10); xlim([0,Inf]);

alrededor de 4 años hace | 0

Respondida
A recursive matrix sum
You function is not recursive function total=ff(l) lp=l(:); if numel(l) == 1 total = l(1); else total = lp(end) + ...

alrededor de 4 años hace | 0

| aceptada

Respondida
Adding a line to my plot3 of a plane
Two lines should be fixed: 1- coordinates of end points of the line 2- Using plot3 %Position vector p1 = [200; -107; 0] %%or...

alrededor de 4 años hace | 0

Respondida
How to solve this function to find z?
Numerical (approximate) solution: syms z; p=4; vpasolve(z/(z-1)*sqrt(z/(2+z))*sqrt(p)==0.32734,z)

alrededor de 4 años hace | 1

Respondida
Index in position 2 exceeds array bounds (must not exceed 8)
The matrix is not square, so you need to find the minimum of row and column numbers. A = [28 -6 4 1 -2 -5 8 0; -4 28 -1 4 0 4 4...

alrededor de 4 años hace | 0

| aceptada

Respondida
Newton's Method to find root of a system of equations
For solving a system of equations, you should solve a system of equation insetead of division: % single equation xn = xn - f(x...

alrededor de 4 años hace | 0

Respondida
Function takes as input two nonempty matrices A and B and returns the product AB
function AB = ex2(A,B) % % % we need rows and columns of both A and B % ColsA should be equal to RowsB [RowsA,ColsA] = size...

alrededor de 4 años hace | 0

| aceptada

Respondida
row elimination problem.
A(all(A(:,1:2)==0,2),:)=[];

alrededor de 4 años hace | 0

Respondida
Matrix Dimensions must agree
change the varibales to vector form: A=[0.05, 0.08, 0.7, 0.01]; E=[125, 80, 100, 150]; L=[0.6, 0.7, 0.2, 0.5]; ndof=length(A...

alrededor de 4 años hace | 0

Respondida
Create a circle in the matrix with zeros
% values N=100; D=ones(N,N); i0=10; j0=20; R=8; % filter indise circle [x,y]=meshgrid(1:N); D((x-i0).^2+(y-j0).^2<R^2)=0...

alrededor de 4 años hace | 1

| aceptada

Respondida
Simple question loop for
You can simply add a disp command to see that nothing will be printed when n=0. It means that the statements inside the loop wil...

alrededor de 4 años hace | 0

Respondida
Compare 2 arrays using for loop and if statement
M =[1 2 3 ; 8 9 0]; e = 2; m = size(M,1); n = size(M,2); M_filter_1 = zeros(size(M)); A =[1 2 3 4 5 6 7 8 9 0]; for a = A...

alrededor de 4 años hace | 1

Respondida
If statement with multiple variables, or if the variables can be shortened.
if x<1 && x<=0.75 a = x - 0.75; elseif x>=0.5 b = x - 0.5; elseif x>=2.5 c = x - 0.25; else d = x; end ...

alrededor de 4 años hace | 0

Respondida
floating point arithmetics, mathlab's interpretation of a . after a number
Matlab sotere double numbers in 8 bytes (64 bits) . So if you do some aritmatic operations, there is an error due to the limits ...

alrededor de 4 años hace | 1

Respondida
Plotting discrete piecewise funtion
piecewise function is for symbolic toolbox. You can use: t=0:0.1:5.0; f= t.*(t>=0 & t<1 ) + exp(-t+1).*(t>=1); plot(t,f);

alrededor de 4 años hace | 0

Respondida
matlab matrix with specific elements
assume that i is from 1 to 5 and j is from 1 to 6: % i: 1 to 5 % j: 1 to 6 [i,j] = meshgrid(1:5,1:6); a=2*(j-4).*(i+1)-3...

alrededor de 4 años hace | 0

| aceptada

Respondida
How to give gap between curves? Please see the attached graph
Do you want something like this? plot (x,y,'Color',[0.4940, 0.1840, 0.5560],'LineStyle','-','LineWidth',1.5) hold on plot (x,...

alrededor de 4 años hace | 0

| aceptada

Respondida
Highlight Region of Sine Graph
% Do you want this? x=linspace(0,2*pi,101); y=sin(x); area(x,y)

alrededor de 4 años hace | 0

| aceptada

Respondida
Stitching together matrices/ indexing matrices
For each k, you should know the connectivity array, for example if the first element is connected to the following degrees of fr...

alrededor de 4 años hace | 1

Respondida
How to use an anonymous function in a ''for''?
if you don't need to use it inside loop. you can define f(x) after for loop: N = 10; %number of elements; l = zeros([N,N]); g...

alrededor de 4 años hace | 0

| aceptada

Respondida
How to plot results from Simpson's Rule integration?
function ask005 %Function to be integrated f=@(x)exp(x); %lower limit a=0; %upper limit b=1; N=[10, 20, 40, 100, 200, 4...

alrededor de 4 años hace | 0

| aceptada

Respondida
For same Matrix subtraction between rows
a(2:2:end,:) = a(1,:)-a(2:2:end,:);

alrededor de 4 años hace | 0

| aceptada

Respondida
How to plot a piecewise function for single cycle? Then repeat the same graph for several times.
This is a sample of function that repeats the graph: % initial x x0=-1; % period T=4; xp=linspace(x0,x0+T,201); % function...

alrededor de 4 años hace | 0

Respondida
Randomly chooses points from a triangular region and stores the x and y coordinates
function [x,y] = hw22(b,h,n) x=rand(n,1)*b; y=rand(n,1)*h; ind=find(y>x*b/h); x(ind)=b-x(ind); y(ind)=h...

alrededor de 4 años hace | 0

Respondida
Randomly chooses points from a triangular region and stores the x and y coordinates
function [x,y] = hw22(b,h,n) x=rand(n,1)*b; y=rand(n,1).*x*h/b; end

alrededor de 4 años hace | 0

Respondida
Randomly chooses points from a triangular region and stores the x and y coordinates
function [x,y] = hw22(b,h,n) % rng('shuffle') x = zeros(1,n); y = zeros(1,n); k = 1; while k <= n xr = h*rand; ...

alrededor de 4 años hace | 0

Respondida
how to arrange vectors in descending order?
% read matrix into A then % sumError = sum(A.^2,2); % sort the total error [~, ind] = sort(sumError,'descend') Asorted = A(...

alrededor de 4 años hace | 1

Respondida
How can i keep repeating the question until they the user makes the correct input?
The start and stop should be defined in the loop as well %User input for start and stop times s = 1; prompt = {'Enter Start t...

alrededor de 4 años hace | 0

Respondida
help with expressing a function
try this: vpa(2/pi*0.01*cos(t),6)

alrededor de 4 años hace | 0

Respondida
How can I ignore 0 values when computing the mean over the third dimensional of a 3D matrix?
You can set 0 values to NaN. Then find the mean of non NaN values; Ap=A; Ap(Ap==0)=NaN; B=mean(Ap,3,'omitnan')

alrededor de 4 años hace | 0

| aceptada

Cargar más