Have equation, need to loop through all data and variables.

조회 수: 1 (최근 30일)
new2matlab
new2matlab 2020년 8월 4일
편집: Raunak Gupta 2020년 8월 8일
I have an equation of answer# = (a+b)*c where a, b, and c, are each a column in a different data structure. How would I go about looping through this 100 times and saving/naming the answer something different for plotting?
  댓글 수: 2
John D'Errico
John D'Errico 2020년 8월 4일
Why do you think you need a loop? Maybe it is time to learn to use MATLAB?
d = (a+b).*c);
new2matlab
new2matlab 2020년 8월 4일
I am trying to learn right now, thanks for the advice though. I am not sure how to construct a loop that brings data into the equation from various data sets that do not match.

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

답변 (1개)

Raunak Gupta
Raunak Gupta 2020년 8월 8일
편집: Raunak Gupta 2020년 8월 8일
Hi,
As John mentioned in the comments you can use element wise multiplication for above equation format. The data structure in which the data is stored can either be in struct format or in vector format (If it's in any other format you can access the individual value appropriately). Finally, you may bring down each variable a,b,c in vector format and can apply what John has suggested.
If the data is stored in different file format you can use this link to figure out how to import the data.

카테고리

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