Display diagonal values from vector answers?

%EXAMPLE
clear all
clc
t=linspace(0,5,6);
x=linspace(10,15,6);
for i=1:length(t)
vec=x*t(i)
end
Is it possible to display/calculate only the diagonal of this, i.e. vec=0 11 24 39 56 75?
Thanks
ewan

 採用された回答

Matt J
Matt J 2013 年 3 月 25 日
編集済み: Matt J 2013 年 3 月 25 日

0 投票

Wouldn't that just be
vec=x.*t
Otherwise, clarify what "diagonal of this" means. As it stands, there are no matrices in your code to speak of and therefore no "diagonal".

3 件のコメント

Ewan
Ewan 2013 年 3 月 25 日
sorry i not the best at explaining. what i'm trying to say is instead of obtaining
vec= 0 0 0 0 0 0
vec=10 11 12 13 14 15
vec=20 22 24 26 28 30
vec=30 33 36 39 42 45
vec=40 44 48 52 56 60
vec=50 55 60 65 70 75
is it possible just display the first value from the first vec (0) and the second value from the second vec (11) etc.? giving
vec= 0 11 24 39 56 75
Matt J
Matt J 2013 年 3 月 25 日
Yes, and as I said x.*t will give you that.
Ewan
Ewan 2013 年 3 月 25 日
sorry didnt notice the (i) isnt required, thanks

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

タグが未入力です。

質問済み:

2013 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by