Display diagonal values from vector answers?

조회 수: 1 (최근 30일)
Ewan
Ewan 2013년 3월 25일
%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