How write closed interval inside loop

Hi,
I have loop from 1:100
and I have v1;v2;v3;l1;u1;l2;u2;l3;u3;m1;m2;m3;g1;g2;g3;
each of them contain 100 numbers.
I need to evaluate g1, and g2, and g3 , from 1:100, by taking the above values,
, with the output of each g1, and g2, and g3 , from 1:100 , as closed interval contain 4 elements as followes:
g1=[ number , number , number , number ], from 1:100
g2=[ number , number , number , number ], from 1:100
g3=[ number , number , number , number ], from 1:100
The attach file , contain error in the reasult.
if any Prof. can help me ...thanks a lot

 採用された回答

David Hill
David Hill 2021 年 4 月 5 日

0 投票

You should just make g1, g2, and g3 matrices. No loop is necessary.
g1=[l1',m1'-2*v1',m1'+3*v1',2*u1'];
g2=[l2',m2'-4*v2',m2'+5*v2',2*u2'];
g3=[l3',m3'-6*v3',m3'+7*v3',2*u3'];

5 件のコメント

hasan s
hasan s 2021 年 4 月 5 日
編集済み: hasan s 2021 年 4 月 6 日
thanks alot for reply
Please, is it possible to add the closed parentheses, to each g1 (g2, g3) output result, such as
[ , , , ]
[ , , , ]
[ , , , ]
and so on
or this is impossible in matlab
David Hill
David Hill 2021 年 4 月 6 日
I am not sure what you are talking about. You can print g1,g2 and g3 in any format.
hasan s
hasan s 2021 年 4 月 6 日
thank you very very much prof. David Hill for your help.
how print g1,g2 and g3 to be in form with closed parentheses as [ , , , ] for every result?is possible in the same program by adding somthing in the program??
David Hill
David Hill 2021 年 4 月 6 日
Look at the function fprintf(). For example look at what this does.
g1=rand(100,4);%100x4 matrix
for k=1:100
fprintf('[%0.5f,%0.5f,%0.5f,%0.5f]\n',g1(k,:));
end
hasan s
hasan s 2021 年 4 月 6 日
That is what I want to got..
thanks alot

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2021 年 4 月 5 日

コメント済み:

2021 年 4 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by