Answered
How do I plot an equation with an imaginary quantity?
Try this: t=[0:0.01:10]; y=exp(-5*1i*t); figure plot(t,real(y), t,imag(y)) legend('Re','Im') You need to plot them sepa...

7 years ago | 0

Answered
How do I find x values from a given (4th degree polynomial) equation and a set of corresponding y values?
I am not certain what you want. One way would be to use the Symbolic Math Toolbox: syms x F(x) = -0.13368*x^4+ 0.358*x^3+...

7 years ago | 0

Answered
solving nonlinear equations in matlab
Use the Symbolic Math Toolbox: syms S P=10; E=5; V=0.33; M=2; K=1.5; B=0.5; H=0.3; T=1; Pfcn=((E*S)/(1-V^2)*M*K^2*B^2...

7 years ago | 1

| accepted

Answered
Relative error: not able to get the right answer.
You need to do element-wise division: erel = eabs./tval*100 ↑ Then it comes close tho the result you wa...

7 years ago | 0

Answered
"Function Keyword is invalid"
The easiest solution is to use an anonymous function instead: vectr = @(x,a,n) ((x-a).^n).*(x>a); You can put that in your sc...

7 years ago | 0

Answered
Problem with ismember with certain numbers in a loop
Use ismembertol instead. You are likely dealing with ‘floating-point approximation error’. See Floating-Point Numbers for a fu...

7 years ago | 2

| accepted

Answered
How do I Annotate my Figure with the Values?
Change your contour call to: contour(M,h/1000,theta,v, 'ShowText','on') See: Contour Properties for more options.

7 years ago | 0

| accepted

Answered
patch with same color as border
The easiest way is to use the patch function EdgeColor property. You can color it to be the same as the patch face color, or yo...

7 years ago | 0

| accepted

Answered
Generating long string with 0 (probability of 0.5) and 1 (probability of 0.5) with space in between two adjacent characters
One approach: N = 25; % String Length v = sprintf('%d ', randi([0 1], 1, N))

7 years ago | 0

| accepted

Answered
Index exceeds the number of array elements (1).
I am guessing that you are passing scalars, not vectors, to your ‘partAQ2’ function. Also, since you are referencing (i+1), y...

7 years ago | 0

| accepted

Answered
To 3Dplot a function that is inside a nested for loop
You are not saving the values of ‘z’ in your loop as a matrix. However there is a more efficient way to do what you want, avo...

7 years ago | 0

| accepted

Answered
Undefined function 'iosize' for input arguments of type 'double'.
This could be a problem: F = (s+10)/(s^3+45*s^2-250^s) ↑ I doubt that ‘250^s’ is supported. Did...

7 years ago | 1

| accepted

Answered
Unable to Access Signal Processing Toolbox Functions
First, run these from a script or your Command Window: restoredefaultpath rehash toolboxcache Then try using the Signal Pr...

7 years ago | 2

Answered
FSOLVE requires all values returned by functions to be of data type double.
The solution is straightforward. Be sure your ‘roottwod’ function returns double-precision values. Note that symbolic values a...

7 years ago | 0

| accepted

Answered
Removing Z-Axis in 3D plot(plot3)
Try this: x = randn(1, 100); % Create Data y = randn(1, 100); % Create Data...

7 years ago | 0

| accepted

Answered
How do I return multiple array values?
If you want both outputs, ask for them! Call your function as: [curvature, moment] = axis_matlab If your function is worki...

7 years ago | 0

| accepted

Answered
Symbolic collect and display
I am not certain what result you want. Try this: [cfs,trm] = coeffs(coeffs_cosy, cos(y)) producing: cfs = [ 4*sin(x), 4...

7 years ago | 1

| accepted

Answered
Undefined variable "Tmax" or class "Tmax".
The error message should also tell you what line Tmax appears on, and if you are calling external functions, the function it app...

7 years ago | 0

| accepted

Answered
Cannot save and open .fig file
I get the same result (error message) with ‘test.fig’ as you posted originally. Wild guess: What do you get when you run:...

7 years ago | 2

| accepted

Answered
unique values from from two column
The description of your problem is at best ambiguous. This produces the result you posted: Output = A(~any(A(:,[2 3]) == 2,...

7 years ago | 0

| accepted

Answered
Filter transfer function using coefficients
Since you have the (a,b) vectors for your filter, use the freqz function to create the Bode plot from them. Your filter appears...

7 years ago | 0

| accepted

Answered
Need help with indexing in a nested for loop
The simplest solution is just to add an extra dimension to ‘DispCurve’. Preallocate as: DispCurve=zeros(length(testVelocity...

7 years ago | 0

| accepted

Answered
How to create image from a matrix?
Try this: A = randn(101,4032); % Create Matrix B = uint8(A); figure imshow(B,[]) There are li...

7 years ago | 0

Answered
solving simple coupled equations
Symbolic Math Toolbox: syms L D Eq1 = D^2* L == 51.8/(1087*25); Eq2 = L/D == 1.178; [Ls,Ds] = solve(Eq1,Eq2,[L,D]); Lv = ...

7 years ago | 0

Answered
Interpolation of Antenna radiated power with respect to Phi(angels)
To interpolate only with respect to , try this: D = load('antenna radiated power.mat'); theta = D.Data1(:,1); phi = D.Data1(...

7 years ago | 0

| accepted

Answered
Value for each loop
Your only option is likely to iterate over the vectors in nested loops: v0=0.01; y =[0.094 0.15]; yv = linspace(min(y), max(...

7 years ago | 0

| accepted

Answered
Unable to find explicit solution
Assuming n-heptane: syms T p1sat p2sat x1 A1= 5.158; B1= 1569.613; C1= -34.846; clog10 = log(10); % heptane A2= 4.028; B2...

7 years ago | 0

Answered
Error lsqcurvefit using Function value and YDATA sizes are not equal.
You need to do element-wise division: fun2 = @(x,xdata)((42*exp((13/7)*x(1)*xdata))-140)./(10+(10* exp((13/7)*x(1)*xdata))); ...

7 years ago | 1

| accepted

Answered
Intersection between the two curves
This approximates your data and calculates and plots the intersections: t = linspace(0, 1500, 250); ...

7 years ago | 0

Answered
Haw can I plot these two equations
Probably the easiest way is to use the contour function: f1 = @(x,y) exp(x).*(sin(y)-cos(y)-(exp(x).*sin(2*y))); f2 = @(x,y) ...

7 years ago | 0

| accepted

Load more