Is there a more efficient way to format my vector rather than manually change the code
2 ビュー (過去 30 日間)
古いコメントを表示
T = 5400;
INT = 900;
tme = 0:INT:T;
TV = [tme(1):30:tme(2)-30, tme(2):15:tme(3)-15, tme(3):12:tme(4)-12, tme(4):2.4:tme(5)-2.4, tme(5):2.1428:tme(6)-2.1428, tme(6):2.5:tme(7)-2.5];
I have this code, however is there an easier way to code this if i want to change the values for 'T' and 'INT' to any random value, for the' TV' vector to automatically update rather than me manually put tme(1), tme(2) etc for those respective values in the 'tme' vector
2 件のコメント
Bruno Luong
2022 年 8 月 16 日
編集済み: Bruno Luong
2022 年 8 月 16 日
Until you explain the law to obtain steps 30, 15, 12, 2.4, 2.1428, 2.5, then no you have to enter it by hand.
採用された回答
David Hill
2022 年 8 月 16 日
TV =@(tme) [tme(1):30:tme(2)-30, tme(2):15:tme(3)-15, tme(3):12:tme(4)-12,...
tme(4):2.4:tme(5)-2.4, tme(5):2.1428:tme(6)-2.1428, tme(6):2.5:tme(7)-2.5];
tv1=TV(0:900:5400);
tv2=TV(0:500:5000);
5 件のコメント
John D'Errico
2022 年 8 月 16 日
It IS (sort of) an answer to your question as posed. I (or anyone) might have been moved to answer a separate question, that was posed more accurately, OR an unaccepted and clarified question. You might even find that David then makes his answer a general solution then.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!