Display diagonal values from vector answers?

1 次查看(过去 30 天)
%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
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 个评论
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by