Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Plotting 3 matrix vs range curves

1 回表示 (過去 30 日間)
s d
s d 2016 年 1 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi everyone,
I have 3 sets of parameter data that I'm attempting to plot against a range of thickness values from 1nm-1um. I have attempted multiple ways of doing this but I believe this way is the closest to retrieving the answer:
clc;clf;
a = [1e-10 7e-10 8e-10];
b = [10e-6 10e-6 10e-6];
for t = 1e-9:1e-9:1000e-9,
Rf = pcu./(w.*t);
end
figure
plot(t,Rf),title('Rf vs. t'),xlabel('t'),ylabel('Rf')
If anyone could give any suggestions or let me know if I'm close to the answer then I'd appreciate it!
Thanks

回答 (1 件)

Kirby Fears
Kirby Fears 2016 年 1 月 14 日
編集済み: Kirby Fears 2016 年 1 月 14 日
I don't know what the values of pcu or w are, but here's a simplification that works fine.
t = 1e-9:1e-9:1000e-9;
Rf = (2.*t);
figure();
plot(t,Rf),title('Rf vs. t'),xlabel('t'),ylabel('Rf');
I don't see a need for the for loop in your code. The dot operations will take care of element-wise multiplication and division.
If you have three separate calculations for t and Rf, you can plot each one separately.
  2 件のコメント
s d
s d 2016 年 1 月 14 日
Thanks for the reply.
Plotting your code is fine. It's when I have the matrix values implemented where the problem lies. Values pcu and w are meant to be a and b (my bad).
I'm basically trying to get 3 separate curves on the same graph for Rf vs. t. It's as though I'm trying to plot this but with 3 sets of values for a and b, as defined in the original post:
clc;clf;
a = 1e-10;
b = 10e-6;
t = 1e-9:1e-9:1000e-9;
Rf = a./(b.*t);
figure
plot(t,Rf),title('Rf vs. t'),xlabel('t'),ylabel('Rf')
Kirby Fears
Kirby Fears 2016 年 1 月 14 日
編集済み: Kirby Fears 2016 年 1 月 14 日
Thanks for the clarification. This should do it:
t = (1e-9:1e-9:1000e-9)';
a = repmat([1e-10, 7e-10, 8e-10],size(t,1),1);
b = repmat([10e-6, 10e-6, 10e-6],size(t,1),1);
t = repmat(t,1,size(a,2));
Rf = a./(b.*t);
plot(t,Rf);
title('Rf vs. t');
xlabel('t');
ylabel('Rf');
Both arrays involved in a dot operation need to have the same dimensions. It won't automatically do all combinations for you. Matrix multiplication could be used here, but replicating the rows and columns is more straightforward.

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by