How can I run an equation to sequentially plug in data from two matrixes of different size?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, I'm extremely new to MATLAB and I'm having some trouble plugging in values to an equation that includes two matrixes
I have a list of known values for rho
rho = [1.59e-8, 1.68e-8, 2.44e-8, 2.82e-8, 1e-7]
and a list of values for length
length =logspace(0,3,10)
Plugged into the equation
P=120^2 * rho * length/.0007
Now if my understanding of things is correct, rho and length are both matrixes (rho being a 1x5, length being a 1x10). But they are not of the same size so simply multiplying them together will not work. I haven't fully wrapped my head around what a matix is and how they interact when there's more than one of them
So what I THINK I need to tell MATLAB to do is take the first value of rho, run the equation to get ten outpus for the values of length. Then, take the next value of rho and repeat the process until there are no more values of rho. I just don't understand how to tell MATLAb to do this. I could write it out manually with a new equation for each value of rho, but I know there is a smarter way.
Any help would be severely appreciated.
0 件のコメント
回答 (1 件)
Sulaymon Eshkabilov
2020 年 9 月 7 日
You'd need to use elementwise operation and : operator to get all calcs done.
rho = [1.59e-8, 1.68e-8, 2.44e-8, 2.82e-8, 1e-7];
length =logspace(0,3,10);
P=120^2 * rho. * length(:)/.0007; % All data computed
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!