Modify last column in a matrix, replacing with an equally spaced range of values?

4 ビュー (過去 30 日間)
Grufff
Grufff 2011 年 3 月 27 日
I'm generating a 42*42 matrix, T, of temperature values. Most interior values are 10 (initial guess for iteration purposes). Row 1 is all 4's, row 42 all -17. I need to make the final column (42) a range of equally spaced values from 4 to -17. What's the best way to do this?
Below is how I'm doing this so far (forgive me, I'm VERY new at this):
T=10*ones(42,42);
T(1,1:end)=4;
T(42,1:end)=-17;
I don't know how to handle the final column simply? I can change the full column with
T(:,end)=new_value
So I've been trying variations on that, say with a range on the right hand side:
T(:,end)=4:-17
But I can't make it work and I'm not having much luck in the help files.
Can anyone set me straight please?

採用された回答

bym
bym 2011 年 3 月 27 日
T(:,42) = linspace(4,-17,42)'
  1 件のコメント
Grufff
Grufff 2011 年 3 月 27 日
Perfect!
Just what I needed, thanks ever so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by