So I figured I want my resistance values to be displayed on a table once I run my code. However, instead of giving me a value for the resistors, it is giving me "1×1 sym" as an answer on the table. I want it to display the actual calculated vale for R1, R2, R3, R4, Vde, and R_ab.
Here's my code:
clear all;clearvars;close all;clc;Vs=10.0; %Supply voltage in Volts
prompt={'Enter value for R_bd: ', 'Enter value for R_ad: ', 'Enter value for R_ae: ', 'Enter value for R_be: ', 'Enter Value for Vad: ', 'Enter Value for Vdb: '};answer=inputdlg(prompt, 's');R_bd = str2double(answer(1));R_ad = str2double(answer(2));R_ae = str2double(answer(3));R_be = str2double(answer(4));Vad = str2double(answer(5));Vdb = str2double(answer(6));syms R1 R2 R3 R4 positive;;equ1=R_bd-R1*(R2+R3+R4)/(R1+R2+R3+R4);equ2=R_ad-R2*(R1+R3+R4)/(R1+R2+R3+R4);equ3=R_ae-R3*(R1+R2+R4)/(R1+R2+R3+R4);equ4=R_be-R4*(R1+R2+R3)/(R1+R2+R3+R4);sol=solve(equ1,equ2,equ3,equ4);R1=sol.R1R2=sol.R2R3=sol.R3R4=sol.R4%Vde is the voltage of node D relative to node E in mV
Vde=(R1/(R1+R2)-R4/(R3+R4))*Vs*1000R_ab=((R1+R2)*(R3+R4))/(R1+R2+R3+R4)I1a=Vad/R2;R1a=Vdb/I1atableData{1,1} = 'R1';tableData{2,1} = 'R2';tableData{3,1} = 'R3';tableData{4,1} = 'R4';tableData{5,1} = 'Vde';tableData{6,1} = 'R_ab';tableData{1,2} = R1;tableData{2,2} = R2;tableData{3,2} = R3;tableData{4,2} = R4;tableData{5,2} = Vde;tableData{6,2} = R_ab;tableData{1,3} = ('Ohms');tableData{2,3} = ('Ohms');tableData{3,3} = ('Ohms');tableData{4,3} = ('Ohms');tableData{5,3} = ('mV');tableData{6,3} = ('Ohms');
If you run it, input any values you want that it asks you it doesn't matter. You will see that if you check the table it generated under tableData 6×3 cell in Workspace, the second column only shows 1×1 sym for the values instead of the calculated number I want it to show.
Is there a way to fix that? If there is another way to tabulate my results that's fine. I just want it tobe in a table format so it is easier to read.
Thank you
Best Answer