Calculation of a sum with variable values from textbox prompt
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I'm looking to get an user input on amount of Resistors, then make an array with that number. Then make a prompt with an input for each resistor value, to be added to the array.
My concrete question is in regards to the prompting, how do i get multiple edit fields in the promt, and connect them to the array,
also accept suggestions for the summing too.
Formula i wish to calculate:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1472556/image.png)
Code so far:
clc, clear, close all;
prompt = {'Enter number of resistors:'};
dlgtitle = 'Number of resistors';
dims = [1 35];
definput = {'1'};
Resistors = inputdlg(prompt,dlgtitle,dims,definput);
R_array = zeros(1,str2double(Resistors(1)))
댓글 수: 3
Dyuman Joshi
2023년 9월 4일
"how do i get multiple edit fields in the promt"
You will get the inputs in the form of a cell array, manipulate them according to your requirements.
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!