3 × 3 hit

5 ビュー (過去 30 日間)
Rusel Ibrahim
Rusel Ibrahim 2021 年 6 月 6 日
コメント済み: Steven Lord 2021 年 6 月 6 日
Q1) write matlab mfile program to input 3x3 A matrix and then call a function that multiply each elements of odd columns from this matrix by 4 then display the result after execute the function?
  1 件のコメント
Steven Lord
Steven Lord 2021 年 6 月 6 日
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

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

回答 (1 件)

Manas Minnoor
Manas Minnoor 2021 年 6 月 6 日
Hi Rusel,
Assuming you want to input the numbers one by one, you may use nested for loops along with the input function, whose documentation are linked below.
To multiply odd columns by 4, you may again use nested for loops along with the colon operator to access only odd columns.
Hope this helps.
  1 件のコメント
DGM
DGM 2021 年 6 月 6 日
select odd columns of A:
A(:,1:2:end);
select even columns of A:
A(:,2:2:end);
no loops needed.
Requiring users to manually input everything anew every time a script is run is just plain bad in my opinion. It's a waste of the user's time and concentration and only promotes errors, but I guess the people writing homework assignments love it. I don't doubt that's the intended way.

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

カテゴリ

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

製品


リリース

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by