Problem with matrix and mesh
Show older comments
Attached (in the images) are the problem, and what the graph is supposed to look like. Here is my code:
% Given Values
C= 15 *(10^-6);
Vm= 24;
L= 240 * 10^-3;
R=[10:1:40];
f=linspace(60,110,31);
w= 2*pi*f;
% Given functions
Top= Vm;
Bottom=sqrt((R.^2)+(w*L-(1./(w.*C))).^2);
I=[Top./Bottom]'
mesh(w,R,I)
When I run it I get this error:
Error using mesh (line 75)
Z must be a matrix, not a scalar or vector.
Error in ICA_4 (line 12)
mesh(w,R,I)
Accepted Answer
More Answers (1)
Jan
on 27 Jan 2017
0 votes
Your w, R and I are vectors with 31 elements. The first input of mesh must be a matrix containing the Z values to the grid of x and y values.
The text of the assignment mentions, that meshgrid should be used.
Notes:
- 15 *(10^-6) is an expensive power operation, while 15e-6 is a cheap constant. The runtime does not matter when you define one constant, but it is a good programming style to consider this.
- 10:40 looks easier and is even faster than [10:1:40], see why-not-use-square-brackets.
1 Comment
Pape Traore
on 28 Jan 2017
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!