Problem with matrix and mesh
이전 댓글 표시
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)
채택된 답변
추가 답변 (1개)
Jan
2017년 1월 27일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
