필터 지우기
필터 지우기

I don't understand what does the question ask!

조회 수: 2 (최근 30일)
Ozan Mirzanli
Ozan Mirzanli 2020년 5월 25일
답변: Image Analyst 2020년 5월 25일
Write a Matlab script to create a random integer matrix with elements between -30 and 30. The size of the matrix must first be read from user input. Use loops to get the sum of each row. Next you will find the differences between all pairs of these sums. Write these differences in a "myout.txt" file, such as "the difference between the totals of lines 1 and 2 is xxx.yyy".
to solve the question,
I really didn't understand what should the sizes of matrix be so i decided it myself to be axb. And I did not understand what does "the size of the matrix must first be read from user input" mean, but i thought:
a=input('Enter the size of rows:');
b=input('Enter the size of columns:');
A=randi([-30 30],a,b)
Then I wanted to use for loop to calculate sum of each row but unfortunately I can't figure it out. I guess the differences between pairs of these sums should be calculated with for loops as well. I've tried to understand these loops by YouTube videos and MATLAB tutorials but I just couldn't. I also did not understand the "writing differences in a "myout.txt" file. I mean should I send two different files to the teacher? (One for programm and the other one is myout.txt) I know it may seem child's play to you but i really am beginner :)
  댓글 수: 2
per isakson
per isakson 2020년 5월 25일
In Matlab there is a function named, sum, and another named diff.
Ozan Mirzanli
Ozan Mirzanli 2020년 5월 25일
편집: Ozan Mirzanli 2020년 5월 25일
thank you genius, I was clear enough that problematic part was about using loops.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2020년 5월 25일
Hint:
a=input('Enter the size of rows:');
b=input('Enter the size of columns:');
A=randi([-30 30],a,b)
for row = 1 : a
theRowSums(row) = sum(A(row,:))
end
dr = diff(
fid = fopen(
fprintf(
fclose(
Try to finish it.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by