how to plot a 2d plot colored map?

1 回表示 (過去 30 日間)
ikram zdeg
ikram zdeg 2019 年 12 月 24 日
コメント済み: Walter Roberson 2020 年 1 月 1 日
Hello
I am trying to creat a 2d plot colored map, I created two for loops for x=vds and y=vgs, and I calculat z=Ids. but all I got is the last calculated value. thank you

回答 (3 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 25 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 25 日
Yes,
for vgs=1:1:2
for vds=1:1:2
%....
end
end
As you assigned input gate voltage (vgs) and output drain voltage (vds) in the for loop assignment. During execution it assign a single value only, like 1 or 2, when the loop execution completed it rflects with last value.
See the following example
>> vgs=1:1:2;
>> disp(vgs)
1 2
In for loop
for vgs=1:1:2
%code
end
#Result
>> disp(vgs)
2
Please go through Matlab Basics

ikram zdeg
ikram zdeg 2019 年 12 月 31 日
thank you for your reply.
so I remove For loops. but when I did it, I get another problem of matrix dimensions must agree.question mat1.PNG
  1 件のコメント
Image Analyst
Image Analyst 2019 年 12 月 31 日
編集済み: Image Analyst 2019 年 12 月 31 日
What is the size of all the variables on that line? Are any of them vectors? Are all vectors the same length? Are any higher dimensional arrays? Are they all the same size also? If they're arrays or vectors you will have to use .* instead of * if you want element-by-element multiplication rather than matrix multiplication.

サインインしてコメントする。


ikram zdeg
ikram zdeg 2020 年 1 月 1 日
thank you for your comment, I used .* instead of * and it works without error. but now my first problem isn't solve it yet after deleting For loops.matlab q2.PNG
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 1 日
Use ./ instead of / in each case.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by