New to matlab please help
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Im brand new to matlab and can't figure this thing out Here is what I'm trying to do I simply want to create a basic plot of a capacitor charge current
Here is the code i wrote
close all
clear all
R = 50,000
C = 2200 * 10^-12
imax = 1/R
tau = R*C
t = [0:.0001:1]
current = imax*exp(-t ./ tau)
axis ([.00000001 .01 0 .01])
plot(t, current)
I can't see the plot no matter how i adjust the axis.The X axis always seems to stay 0 to 1 I don't understand why. Please rescue me. I spend more time fighting with this then i do actually doing my homework
採用された回答
Chad Greene
2014 年 7 月 1 日
編集済み: Chad Greene
2014 年 7 月 1 日
A couple of things:
Make a habit of ending lines with a semicolon (;) to suppress the output. It doesn't make a big difference now, but later down the road with big data, printing the output will slow down processing.
Your R value is being read as 50 instead of 50000. If there are too many zeros for pleasant reading, you could type R = 50e+3.
Try semilogy instead of plot to show this data.
R = 50000;
C = 2200e-12;
imax = 1/R;
tau = R*C;
t = [0:.0001:1];
current = imax*exp(-t ./ tau);
axis ([.00000001 .01 0 .01]);
semilogy(t, current)
8 件のコメント
Robert
2014 年 7 月 1 日
Thank you very much for taking the time to write. the 50,000 helped. It looks a little better. The semiology I'm assuming would come in handy for bode plots. I still would really like to get the regular plot working. The plot actually shows up not but still can't get the axis right to make it look normal. I added many values of t to help with smoothing the curve. Any recommendations on how to get a good look at this?
Chad Greene
2014 年 7 月 1 日
編集済み: Chad Greene
2014 年 7 月 1 日
Actually, I see that you were attempting to set the axis limits before plotting the data. Set the axes after plotting the data. Like this:
plot(t, current)
axis([1e-8 .01 0 .01]);
Chad Greene
2014 年 7 月 1 日
You have plenty of values of t. It will still probably look a little jagged in the figure window, because Matlab figures are a bit ugly by default. If you want to save smooth, attractive figures, use export_fig .
Robert
2014 年 7 月 1 日
Thanks. The axis after the plot seemed to help a little but i still have no curve Its just a flat line. I don't get it Here is the code now
%d
close all;
clear all;
R = 50000;
C = 2200 * 10^-12;
imax = 1/R;
tau = R*C;
t = [0:.001:.5];
current = imax*exp(-t./tau);
plot(t, current)
axis ([0 .001 0 .5]);
Chad Greene
2014 年 7 月 1 日
It's plotting the curve in blue, but the maximum value in your current is 2x10^-5. That's very small compared to the limit of your y axis that you have set as 0.5. The result is a blue curve that looks like a flat line at the bottom of the graph.
You can specify the x limits without specifying the y limits, and Matlab will usually do an okay job of guessing the appropriate y limits. To do this, delete the axis line and replace it with
xlim([0 .001]);
Robert
2014 年 7 月 1 日
You sir just got yourself added to my xmass card list! Thank you!!
Chad Greene
2014 年 7 月 1 日
Glad to hear it.
On a side note, this is clunky: C = 2200 * 10^-12;.
Consider adopting this syntax instead: C = 2200e-12;
Robert
2014 年 7 月 1 日
will do. This is like my second day trying matlab so i appreciate the suggestions. Im still not 100% sure what i can and can't do. I have a C, C++ background and a few HDL,s and latex but don't know any matlab. Thanks again!
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
