필터 지우기
필터 지우기

trying to multiply and divide different size matices

조회 수: 1 (최근 30일)
A Poyser
A Poyser 2023년 5월 22일
댓글: FannoFlow 2023년 5월 22일
I am trying to make sense of this line
cdp = cdp_initial + cdp_increment * (sigma_range / KIc) * N_cycles;
However, the matrix for sigma_range is 1x11. However KIc, and N_cycles are both 6x6
Is there a logical way to perfrom this operation?
Thanks in advance
Alex
  댓글 수: 1
Adam Danz
Adam Danz 2023년 5월 22일
편집: Adam Danz 2023년 5월 22일
When you see a size mismatch like this, three possible explanations come to mind
  1. something is wrong with the size of the data in the inputs
  2. the variables are being computed incorrectly
  3. the variables and computations are fine but the line of code is not correct
Where I would start troubleshooting depends on context. If lots of others have used this code without problems and it comes from a reputable source, I'd start with #1, assuming I screwed up the inputs.
If I wrote the code yesterday after losing sleep for 3 days and was suspicious that gnomes may have messed with my code, I'd start with #3 after checking that the inputs make sense.
If you confirmed that the code is not the problem and your inputs are correct, then start with #2.

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

채택된 답변

Image Analyst
Image Analyst 2023년 5월 22일
Not that I know of. It throws an error, right? Can't you ask the original author what their thinking was?
  댓글 수: 2
A Poyser
A Poyser 2023년 5월 22일
yes it generates an error
FannoFlow
FannoFlow 2023년 5월 22일
A possible "solution" could be to multiply the 6x6 each by the 1x11, generating a 6x6x11 matrix.
You'd do this by reshaping the 1x11 matrix to a 1x1x11 matrix reshape(data, 1,1,[]) and then multiplying.
After that, I'm not sure. perhaps this is inteded to be used in some sort of mean? Either way you need to sort out the logic and intent behind the program here before moving forward.
```

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by